예제 #1
0
 public Client(TcpClient tcpc, Server server)
 {
     this.tcpc = tcpc;
     this.tcpc.ReceiveTimeout = 15000;
     this.tcpc.SendTimeout = 15000;
     this.Reader = new StreamReader(tcpc.GetStream());
     this.Reader.BaseStream.ReadTimeout = 15000;
     this.Writer = new StreamWriter(tcpc.GetStream());
     this.Writer.BaseStream.WriteTimeout = 15000;
     inputThread = new Thread(listenForInput);
     inputThread.Name = "InputThread::" + tcpc.Client.RemoteEndPoint;
     listening = true;
     inputThread.Start();
     this.Server = server;
     OnConnect(this, new ConnectionEventArgs(this));
     Server.OnConnect(this, new ConnectionEventArgs(this));
 }
예제 #2
0
        public void StartHosting()
        {
            try
            {
                if (IsHosting)
                {
                    HostedServer.Stop();
                    SyncTimer.Stop();
                }

                HostedServer = new Server(HostPort);
                HostedServer.Start();
                HostedServer.Input += OnHostInput;
                HostedServer.Output += OnHostOutput;
                HostedServer.Connect += OnHostConnect;
                HostedServer.Disconnect += OnHostDisconnect;
                SyncTimer.Start();
            }
            catch (Exception e)
            {
                StopHosting();
                Debug.Log(e);
            }
        }
예제 #3
0
 private void OnLoad(object sender, EventArgs e)
 {
     Server = new Server(25564);
     Server.Start();
 }