//  handlers
    private void HandleChatMessage(ArraySegment <byte> chatData)
    {
        var chat = chatData.Deserialize <ChatPacket>();

        //  log to view
        _chatPanel.AddLog(chat.author + ": " + chat.entry);
    }
    private void GreetHandleMessage(ArraySegment <byte> chatData)
    {
        var greet = chatData.Deserialize <GreetPacket>();

        _chatPanel.AddLog(greet.greetMessage);
        _chatPanel.AddLog("Connection id: " + greet.id);
    }
    //  handlers
    private void HandleChatMessage(ArraySegment <byte> data)
    {
        var chat = data.Deserialize <ChatPacket>();

        Debug.Log("received chat, author: " + chat.author);

        var msg = new Message()
        {
            header = "chat",
            packet = data
        };

        _server.SendAll(msg.Serialize());
    }
Example #4
0
    public void Handle(ArraySegment <byte> data)
    {
        var msg = data.Deserialize <Message>();

        _handlers[msg.header](msg.packet);
    }