Пример #1
0
        protected virtual void SendComplete(object sender, IOTaskCompleteEventArgs <SocketSendTask> e)
        {
            e.Task.Completed -= SendComplete;

            var msg = (IPacket)e.Task.UserToken;

            if (msg.Id == (byte)AresId.MSG_CHAT_SERVER_HTML)
            {
            }

            if (e.Task.Exception == null)
            {
                Monitor.AddOutput(e.Task.Transferred);
                try {
                    PacketSent?.Invoke(this, new PacketEventArgs(msg, MessageType, e.Task.Transferred));

                    if (IsConnected)
                    {
                        SendQueue();
                    }
                }
                catch (Exception ex) {
                    OnException(ex);
                }
            }
            else
            {
                OnException(e.Task.Exception);
            }
        }
Пример #2
0
        private void SendComplete(object sender, IOTaskCompleteEventArgs <SocketSendTask> e)
        {
            e.Task.Completed -= SendComplete;

            if (e.Task.Exception == null)
            {
                Monitor.AddOutput(e.Task.Transferred);
                try {
                    var msg = (IPacket)e.Task.UserToken;

                    var complete = PacketSent;
                    if (complete != null)
                    {
                        complete(this, new PacketEventArgs(msg, e.Task.Transferred, e.Task.RemoteEndPoint));
                    }
                }
                catch (Exception ex) {
                    OnException(ex, e.Task.RemoteEndPoint);
                }
            }
            else
            {
                OnException(e.Task.Exception, e.Task.RemoteEndPoint);
            }
        }
Пример #3
0
        private void SendComplete(object sender, IOTaskCompleteEventArgs <SocketSendTask> e)
        {
            sending           = false;
            e.Task.Completed -= SendComplete;

            if (e.Task.Exception == null)
            {
                Monitor.AddOutput(e.Task.Transferred);
                try {
                    var msg = (IPacket)e.Task.UserToken;

                    var complete = PacketSent;
                    if (complete != null)
                    {
                        complete(this, new PacketEventArgs(msg, e.Task.Transferred));
                    }

                    if (Connected)
                    {
                        SendQueue();
                    }
                }
                catch (Exception ex) {
                    OnException(ex);
                }
            }
            else
            {
                OnException(e.Task.Exception);
            }
        }
Пример #4
0
        private void SendComplete(object sender, IOTaskCompleteEventArgs <SocketSendTask> e)
        {
            e.Task.Completed -= sendHandler;

            if (e.Task.Exception == null)
            {
                Monitor.AddOutput(e.Task.Transferred);

                try {
                    var msg = (IPacket)e.Task.UserToken;
                    PacketSent?.Invoke(this, new PacketEventArgs(msg, WebSocketMessageType.Binary, e.Task.Transferred, e.Task.RemoteEndPoint));
                }
                catch (Exception ex) {
                    OnException(ex, e.Task.RemoteEndPoint);
                }
            }
            else
            {
                OnException(e.Task.Exception, e.Task.RemoteEndPoint);
            }
        }