private void OnClientConnect(IAsyncResult ar) { try { Socket clientSocket = socket.EndAccept(ar); var connection = new Connection(clientSocket, this); connection.DataSent += HandleDataSent; connection.DataReceived += HandleDataReceived; connection.ClientDisconnected += HandleClientDisconnected; connection.BeginListen(); lock (Lock) { connections.Add(connection); } ClientConnect?.Invoke(this, new ConnectionArgs(connection)); socket.BeginAccept(new AsyncCallback(OnClientConnect), null); } catch (ObjectDisposedException) { // Object is disposed, let the thread die. } }
/// <summary>This is the callback when a client connects</summary> /// <param name="asyncResult">TODO: What is this?</param> private void OnClientConnect(IAsyncResult asyncResult) { try { // Here we complete/end the BeginAccept() asynchronous call // by calling EndAccept() - which returns the reference to // a new Socket object Socket socket = mainSocket.EndAccept(asyncResult); var conn = new Connection(socket, this); conn.DataSent += EventHandlerDataSent; conn.DataReceived += EventHandlerDataReceived; conn.ClientDisconnected += EventHandlerClientDisconnected; // Let the worker Socket do the further processing for the // just connected client conn.ListenForData(); lock (LockObject) { connections.Add(conn); } // Raise our client connect event. ClientConnect?.Invoke(this, new ConnectionArgs(conn)); // Since the main Socket is now free, it can go back and wait for // other clients who are attempting to connect mainSocket.BeginAccept(OnClientConnect, null); } catch (ObjectDisposedException) { // This exception was preventing the console from closing when the // shutdown command was issued. } }
protected internal void OnClientConnect(TcpSocketEventArgs arg) { clients.Add(arg.Client); arg.Client.Load(); ClientConnect?.Invoke(this, arg); }
public override void OnConnection(VMEODClient client) { if (client.Avatar != null) { if (EODType.Equals(VMEODGameshowBuzzerPluginType.Player)) // player connected to player object { // new player has connected event ClientConnect?.Invoke(); } } else { Controller = client; } SyncEvent += SyncExecutor; base.OnConnection(client); }
internal static void InvokeClientConnect(ClientConnectEventArgs e) { ClientConnect?.Invoke(e); }
/// <summary> /// Вызов события о новом подключении /// </summary> /// <param name="id">ID сокета</param> /// <param name="ip">IP адрес подклоючения</param> /// <param name="port">Удаленный порт</param> private void CallConnected(ConnectionValue client) { Task.Factory.StartNew(() => { ClientConnect?.Invoke(this, new Arguments.ClientConnectionArgs(client.SocketID, client.RemoteIP, client.RemotePort)); }); }
public virtual void OnClientConnect(ClientConnectEventArgs e) { ClientConnect?.Invoke(this, e); }
private void OnConnect(ConnectEventArgs e) { UnityEngine.Debug.Log("OnConnect " + e.Socket.RemoteEndPoint); ClientConnect?.Invoke(this, e); }
private void OnClientConnect(PacketReceivedEventArgs packetReceivedEventArgs) { ClientConnect?.Invoke(this, packetReceivedEventArgs); }