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;
 }
Example #2
0
        /// <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;
            }
        }
Example #3
0
 public void OnRemoteClientAdded(TCPRemoteClient remoteClient)
 {
     remoteClient.Register(this);
 }
Example #4
0
 private void NotifyRemoteClientAdded(TCPRemoteClient remoteClient)
 {
     foreach (ITCPServerEventHandler handler in _ITCPServerEventHandler)
     {
         handler.OnRemoteClientAdded(remoteClient);
     }
 }
Example #5
0
 /// <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);
 }
Example #6
0
        /// <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();
        }