private void InvokeDisconnection(IProcessor processor) { if (OnDisconnection != null) { OnDisconnection.BeginInvoke(processor, null, null); } }
private void lblStatus_Click(object sender, EventArgs e) { if (connected) { OnDisconnection?.Invoke(); } }
[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(); }
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."); }); }
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()); } } }
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; } }
private void disconnettiToolStripMenuItem_Click(object sender, EventArgs e) { OnDisconnection?.Invoke(); }
public void InvokeDisconnection(bool disconnectedByUser) { OnDisconnection?.Invoke(disconnectedByUser); }
public static void CallDisconnection() => OnDisconnection?.Invoke();