public RemoteClientMessageService(TCPRemoteClient remoteClient, IRemoteClientMessageDelegate remoteClientMessageDelegate) { _remoteClient = remoteClient; //KTODO may be better to have a start/stop method on this so that it can unregister //from the given remote client remoteClient.Register(this); _remoteClientMessageDelegate = remoteClientMessageDelegate; }
/// <summary> /// Retrieves the remote client with the given ID /// </summary> /// <param name="remoteClientID"></param> /// <returns></returns> public bool GetTCPRemoteClient(uint remoteClientID, out TCPRemoteClient remoteClient) { remoteClient = null; try { _clientDirectory.TryGetValue(remoteClientID, out remoteClient); return true; } catch (Exception e) { Log.debug("Error:" + e.Message); return false; } }
public void OnRemoteClientAdded(TCPRemoteClient remoteClient) { remoteClient.Register(this); }
private void NotifyRemoteClientAdded(TCPRemoteClient remoteClient) { foreach (ITCPServerEventHandler handler in _ITCPServerEventHandler) { handler.OnRemoteClientAdded(remoteClient); } }
/// <summary> /// Adds given TCPRemoteClient object to the client directory /// </summary> /// <param name="client"></param> private void AddRemoteClient(TCPRemoteClient remoteClient) { _clientDirectory.Add(remoteClient.ClientID, remoteClient); Log.debug("Client added"); NotifyRemoteClientAdded(remoteClient); }
/// <summary> /// Builds a TCPRemoteClient instance object upon a client connection being established /// </summary> /// <param name="client">The socket of the remote client that connected</param> void IClientConnectionListenerDelegate.OnClientConnected(Socket client) { //Build the remote client TCPRemoteClient tcpClient = new TCPRemoteClient(_clientIDIndex, client, this); //Add it to the system AddRemoteClient(tcpClient); //Increment the ID index _clientIDIndex++; //Allow the remote client to start receiving tcpClient.StartReceive(); }