예제 #1
0
        private void HandleMessage(object sender, TransportMessageEventArgs args)
        {
            var buffer  = args.Buffer;
            var message = _messageSerializer.Deserialize(buffer.Span);

            var remote = new SwimHost(args.RemoteEndpoint);

            switch (message.Type)
            {
            case SwimMessageType.Ping:
                OnPing?.Invoke(this, new TransportPingEventArgs(message as PingMessage, remote));
                break;

            case SwimMessageType.PingReq:
                OnPingReq?.Invoke(this, new TransportPingReqEventArgs(message as PingReqMessage, remote));
                break;

            case SwimMessageType.Ack:
                OnAck?.Invoke(this, new TransportAckEventArgs(message as AckMessage, remote));
                break;

            case SwimMessageType.Sync:
                OnSync?.Invoke(this, new TransportSyncEventArgs(message as SyncMessage, remote));
                break;

            case SwimMessageType.Update:
                OnUpdate?.Invoke(this, new TransportUpdateEventArgs(message as UpdateMessage, remote));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #2
0
        private void webSocket_OnMessage(string text)
        {
            var data = Event.NewEvent(text);

            if (data.Type == "hello")
            {
                RecievedHello = true;
            }
            if (data is Ack)
            {
                OnAck?.Invoke(this, new SlackEventArgs(data));
            }
            else
            {
                OnEvent?.Invoke(this, new SlackEventArgs(data));
            }
        }
예제 #3
0
 public void Ack()
 {
     _channel.BasicAck(_deliveryTag, false);
     OnAck?.Invoke(this, new EventArgs());
 }