Exemplo n.º 1
0
		public UChannel(USocket socket, UService service): base(service)
		{
			this.isConnected = true;
			this.socket = socket;
			this.service = service;
			this.remoteAddress = this.socket.RemoteAddress;
		}
Exemplo n.º 2
0
 public UChannel(USocket socket, UService service) : base(service)
 {
     this.isConnected   = true;
     this.socket        = socket;
     this.service       = service;
     this.remoteAddress = this.socket.RemoteAddress;
 }
Exemplo n.º 3
0
		public void ClientSendToServer()
		{
			const string hostName = "127.0.0.1";
			const ushort port = 8889;
			using (IService clientService = new UService(hostName, 8888))
			{
				using (IService serverService = new UService(hostName, 8889))
				{
					Task task1 = Task.Factory.StartNew(() =>
					{
						while (!this.isClientStop)
						{
							clientService.Update();
						}
					}, TaskCreationOptions.LongRunning);

					Task task2 = Task.Factory.StartNew(() =>
					{
						while (!this.isServerStop)
						{
							serverService.Update();
						}
					}, TaskCreationOptions.LongRunning);

					// 往server host线程增加事件,accept
					serverService.Add(() => this.ServerEvent(serverService));

					Thread.Sleep(1000);

					// 往client host线程增加事件,client线程连接server
					clientService.Add(() => this.ClientEvent(clientService, hostName, port));
					this.barrier.SignalAndWait();

					serverService.Add(() => { this.isServerStop = true; });
					clientService.Add(() => { this.isClientStop = true; });
					Task.WaitAll(task1, task2);
				}
			}
		}
Exemplo n.º 4
0
		public UChannel(USocket socket, string host, int port, UService service): base(service)
		{
			this.socket = socket;
			this.service = service;
			this.remoteAddress = host + ":" + port;
		}
Exemplo n.º 5
0
 public UChannel(USocket socket, string host, int port, UService service) : base(service)
 {
     this.socket        = socket;
     this.service       = service;
     this.remoteAddress = host + ":" + port;
 }