---
title: "messages(of:)"
framework: groupactivities
role: symbol
role_heading: Instance Method
path: "groupactivities/groupsessionmessenger/messages(of:)-jvoz"
---

# messages(of:)

Returns the asynchronous sequence of messages that match the app-specific type.

## Declaration

```swift
final func messages<Message>(of type: Message.Type) -> GroupSessionMessenger.Messages<Message> where Message : Decodable, Message : Encodable
```

## Parameters

- `type`: The class of the custom type you use to package the message contents.

## Discussion

Discussion Call this method to receive the messages that other participants send to the group. This method returns a GroupSessionMessenger.Messages structure, which conforms to the AsyncSequence protocol. This sequence contains all, some, or none of the messages sent over time. You retrieve messages by iterating over them using an asynchronous for-in loop, as shown in the following example: let sessionMessenger = GroupSessionMessenger(session: groupSession)

async {     for await move in sessionMessenger.messages(of: TicTacToe.Move.self) {         self.board.addMove(move)     } }

## See Also

### Receiving data from other participants

- [messages(of:)](groupactivities/groupsessionmessenger/messages(of:)-626qo.md)
- [GroupSessionMessenger.Messages](groupactivities/groupsessionmessenger/messages.md)
- [GroupSessionMessenger.MessageContext](groupactivities/groupsessionmessenger/messagecontext.md)
