コード例 #1
0
ファイル: Server.cs プロジェクト: ewin66/Monitor
 private void InvokeDisconnection(IProcessor processor)
 {
     if (OnDisconnection != null)
     {
         OnDisconnection.BeginInvoke(processor, null, null);
     }
 }
コード例 #2
0
ファイル: Main.cs プロジェクト: leon289/vpn_manager
 private void lblStatus_Click(object sender, EventArgs e)
 {
     if (connected)
     {
         OnDisconnection?.Invoke();
     }
 }
コード例 #3
0
        [ConditionalShow, SerializeField] private bool useless; //在没有数据的时候让标题正常显示
#endif

        private void Awake()
        {
            NetworkSystem.OnUDPReceive    += val => OnUDPReceive?.Invoke(val.message);
            NetworkSystem.OnReceive       += val => OnReceive?.Invoke(val);
            NetworkSystem.OnConnection    += () => OnConnection?.Invoke();
            NetworkSystem.OnDisconnection += () => OnDisconnection?.Invoke();
        }
コード例 #4
0
ファイル: BluetoothClient.cs プロジェクト: EFinley/Atropos
 public BluetoothClient(CancellationToken?stopToken = null) : base(stopToken)
 {
     _cts.Token.Register(() =>
     {
         inStream?.Dispose();
         outStream?.Dispose();
         socket?.Close();
         OnDisconnection?.Invoke(this, EventArgs.Empty);
         Log.Debug(_tag, "CTS token fired.");
     });
 }
コード例 #5
0
        private async Task Receive(Context context)
        {
            var stream = context.TcpClient.GetStream();

            while (_running)
            {
                // First time the client connects, an opening statement of 4 bytes is sent that needs to be ignored
                if (!context.Initialized)
                {
                    var openingStatementBuffer = new byte[4];
                    await stream.ReadAsync(openingStatementBuffer, 0, openingStatementBuffer.Length);

                    context.InitializeClient();
                }

                // Header determines size of message
                var headerBuffer = new byte[2];
                var read         = await stream.ReadAsync(headerBuffer, 0, headerBuffer.Length);

                if (read == 0)
                {
                    OnDisconnection?.Invoke(context);
                    break;
                }

                var messageLength = BitConverter.ToInt16(headerBuffer, 0) - headerBuffer.Length;
                var messageBuffer = new byte[messageLength];
                read = await stream.ReadAsync(messageBuffer, 0, messageLength);

                Debug.WriteLine("RECEIVED RAW: " + BitConverter.ToString(messageBuffer));

                try
                {
                    IMessage message = MessageSerializer.Deserialize(messageBuffer);
                    Console.WriteLine("Recv message[{0},{1}]: {2}",
                                      context.User != null ? context.User.Username : "******",
                                      context.User != null ? context.User.UserId : -1,
                                      message);
                    OnReceive?.Invoke(context, message);
                }
                catch (UnknownMessageTypeException messageTypeEx)
                {
                    Debug.WriteLine(messageTypeEx.ToString());
                }
                catch (UnknownXFireAttributeTypeException attributeTypeEx)
                {
                    Debug.WriteLine(attributeTypeEx.ToString());
                }
            }
        }
コード例 #6
0
ファイル: APNetwork.cs プロジェクト: adrenak/airpeer
        void ProcessNetworkEvent(NetworkEvent e)
        {
            switch (e.Type)
            {
            case NetEventType.ServerInitialized:
                OnServerStartSuccess?.Invoke(e);
                break;

            case NetEventType.ServerInitFailed:
                OnServerStartFailure?.Invoke(e);
                break;

            // Received after network.StopServer
            case NetEventType.ServerClosed:
                OnServerStopped?.Invoke(e);
                break;


            case NetEventType.NewConnection:
                OnNewConnection?.Invoke(e);
                break;

            case NetEventType.ConnectionFailed:
                OnConnectionFailed?.Invoke(e);
                break;

            case NetEventType.Disconnected:
                OnDisconnection?.Invoke(e);
                break;


            case NetEventType.ReliableMessageReceived:
                OnMessageReceived?.Invoke(e, true);
                break;

            case NetEventType.UnreliableMessageReceived:
                OnMessageReceived?.Invoke(e, false);
                break;
            }
        }
コード例 #7
0
ファイル: Main.cs プロジェクト: leon289/vpn_manager
 private void disconnettiToolStripMenuItem_Click(object sender, EventArgs e)
 {
     OnDisconnection?.Invoke();
 }
コード例 #8
0
 public void InvokeDisconnection(bool disconnectedByUser)
 {
     OnDisconnection?.Invoke(disconnectedByUser);
 }
コード例 #9
0
 public static void CallDisconnection() => OnDisconnection?.Invoke();