private void OnPool_ProcessItem(TcpSocketServer.ClientsInfo item) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "OnPool_ProcessItem"); try { while (!_executorService.WaitForShutdown(_clientWaitTimeout)) { try { if (item.InternalSockets.Length > 0) { IList temp = new List <Socket>(item.InternalSockets); try { Socket.Select(temp, null, null, this.PollTimeout); for (int i = 0; i < temp.Count; i++) { Socket clientSocket = (Socket)temp[i]; if (clientSocket != null) { INetSocketHandler client = item[clientSocket]; if (client != null) { if (clientSocket.Available > 0) { byte[] buffer = new byte[clientSocket.Available]; client.Read(buffer, 0, buffer.Length); this.OnReceivedBytes(client, buffer); } } } } } catch (SocketException) { // no need to log } catch (Exception ex) { Log.Exception(PROC, ex); } } } catch (Exception ex) { Log.Exception(PROC, ex); } } } catch (Exception ex) { Log.Exception(PROC, ex); } }
bool OnSocket_ReceivedBytes(INetSocketHandler client, byte[] data) { this.OnDataReceived(new UdpSocketReceiveData() { Buffer = data, BufferLength = data.Length, RemoteEndpoint = client.RemoteEndPoint, }); return(true); }
private void OnClientConnected(INetSocketHandler client) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "OnClientConnected"); try { if (this.ClientConnected != null) { this.ClientConnected(this, client); } } catch (Exception ex) { Log.Exception(PROC, ex); } }
protected bool OnReceivedBytes(INetSocketHandler socket, byte[] data) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "OnClientReadBytes"); try { if (this.ReceivedBytes != null) { return(this.ReceivedBytes(socket, data)); } } catch (Exception ex) { Log.Exception(PROC, ex); return(false); } return(true); }
public void AddClient(INetSocketHandler client) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "AddClient"); try { int hashcode = client.GetHashCode(); if (!_clients.ContainsKey(hashcode)) { _clients.Add(hashcode, client); _clients2.Add(client.InternalSocket, client); } } catch (Exception ex) { Log.Exception(PROC, ex); } finally { this.PrepareHandles(); } }
protected bool OnReceivedBytes(INetSocketHandler socket, byte[] data) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "OnClientReadBytes"); try { if (this.ReceivedBytes != null) { return this.ReceivedBytes(socket, data); } } catch (Exception ex) { Log.Exception(PROC, ex); return false; } return true; }