Ejemplo n.º 1
0
		protected virtual void AcceptCallback(IAsyncResult ar)
		{
//			if (true)
//				;
			// todo
			// it's a base implemtation and virtual
			AcceptObject obj = ((AcceptObject)ar.AsyncState);
			obj.allDone.Set();
			Socket handler = obj.listener.EndAccept(ar);

			Console.WriteLine("Accept connection from: " + handler.RemoteEndPoint.ToString());
			lock (this._clients)
			{
				BaseConnection connection = new BaseConnection(handler, this); // use the same interpretor

				this.AddID(connection.ID);
				// OnConnected
				this._clients.Add(connection);
				this.OnAcceptedConnection(connection);
			}
		}
Ejemplo n.º 2
0
		public virtual void AddConnection(Socket client)
		{
			// throw new NotImplementedException();
			Debug.WriteLine(this + ".AddConnection from socket");

//			Socket handler = client.Accept();

			Console.WriteLine("Accept connection from: " + client.RemoteEndPoint.ToString());
			lock (this._clients)
			{
				BaseConnection connection = new BaseConnection(client, this); // use the same interpretor

				this.AddID(connection.ID);
				// OnConnected
				this._clients.Add(connection);
				this.OnAcceptedConnection(connection);
			}
		}
Ejemplo n.º 3
0
		private void OnAcceptedConnection(BaseConnection connection)
		{
			if (this.AcceptedConnection != null)
			{
				this.AcceptedConnection(connection);
			}
		}