Processing Message

Re: Processing Message

by Haoqian Zhang -
Number of replies: 0
Here is an example of a handler from the design document[1]:

// The handler. This function will be called when a chat message is received.
func (m XXX) ExecChatMessage(msg types.Message, pkt transport.Packet) error {
    // cast the message to its actual type. You assume it is the right type.
    chatMsg, ok := msg.(*types.ChatMessage)
    if !ok {
        return xerrors.Errorf("wrong type: %T", msg)
    }

    // do your stuff here with chatMsg...
    
    return nil
}
You can place an outgoing queue and peer configuration in XXX (could be messaging) so that in the exec function, you will be able to access all the things you need. 

Hope it helps.

[1]https://github.com/dedis/cs438/tree/cs438-2021-rewrite/docs