コード例 #1
0
        public void setManager(ClientThread manager)
        {
            this.Manager = manager;
            Manager.ClientListener.OnFileTransferListing += ClientListener_OnFileTransferListing;

            InitTrees();
        }
コード例 #2
0
ファイル: Help.cs プロジェクト: Gremlin13/StarryboundServer
        public Help(ClientThread client)
        {
            this.name = "Help";
            this.HelpText = ": Provides help for using commands.";
            this.aliases = new string[] {"?", "commands", "commandlist"};

            this.client = client;
            this.player = client.playerData;
            commands =  new CommandBase[] {
                new BanCommand(client),
                new BanReloadCommand(client),
                new Broadcast(client),
                new Build(client),
                new Find(client),
                new GroupCommand(client),
                new Home(client),
                new Item(client),
                new Kick(client),
                new MeCommand(client),
                new Mute(client),
                new Planet(client),
                new Players(client),
                new Rules(client),
                new Ship(client),
                new Shutdown(client),
                new Uptime(client),
                new WarpShip(client),
                new WhosThereCommand(client),
            };
        }
コード例 #3
0
        //the entrance function for communication, will be called by firstScreen function after all initialization finished
        public static void comProccess()
        {
            int         i;
            Socket      socket;
            string      strIPAddr = "";
            string      HostName  = Dns.GetHostName();
            int         portNum   = 8899;
            IPAddress   ip;
            IPEndPoint  ipep;
            IPHostEntry IpEntry = Dns.GetHostEntry(HostName);

            try
            {
                for (i = 0; i < IpEntry.AddressList.Length; i++)
                {
                    if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
                    {
                        strIPAddr = IpEntry.AddressList[i].ToString();
//                        if (strIPAddr.Remove(7) == "172.30.")
//                        if (strIPAddr.Remove(7) == "192.168")
//                        if (strIPAddr.Remove(7) == "10.10.1")
//                        if (strIPAddr == gVariable.communicationHostIP)
                        break;
                    }
                }

                if (i >= IpEntry.AddressList.Length)
                {
                    Console.Write("IPv4 address not found!");
                    return;
                }

                ip   = IPAddress.Parse(strIPAddr);
                ipep = new IPEndPoint(ip, portNum);

                socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                socket.Bind(ipep);
                socket.Listen(10);

//                if (DateTime.Now.Year > 2017 || (DateTime.Now.Year == 2017 && DateTime.Now.Month >= 12))
//                    return;

                while (true)
                {
                    Socket client = socket.Accept();  // TCP server is now in listening mode, trying to find a client

                    //a new client sent out its first TCP data packet, TCP server knows a new connection is now available
                    //although there is still no real data, only TCP packet  -> Flag1
                    ClientThread newclient = new ClientThread(client);
                    //now move to ClientThread()
                    Thread newthread = new Thread(new ThreadStart(newclient.ClientServer));
                    newthread.Start();
                    toolClass.nonBlockingDelay(80);
                }
            }
            catch (Exception ex)
            {
                Console.Write("create multithread fail!" + ex);
            }
        }
コード例 #4
0
    static public void Main(string[] args)
    {
        Storage storage = StorageFactory.Instance.CreateStorage();

        storage.Open(new NullFile(), 0);
        Database db = new Database(storage, true);

        DateTime start = DateTime.Now;

        Thread[] threads = new Thread[nThreads];
        for (int i = 0; i < nThreads; i++)
        {
            ClientThread client = new ClientThread(db, i);
            threads[i] = new Thread(new ThreadStart(client.run));
            threads[i].Start();
        }
#if !COMPACT_NET_FRAMEWORK
        for (int i = 0; i < nThreads; i++)
        {
            threads[i].Join();
        }
        storage.Close();
#endif
        Console.WriteLine("Elapsed time: " + (DateTime.Now - start));
    }
コード例 #5
0
ファイル: TestDriver.cs プロジェクト: 411blue/echo-backup
        //tests sending a QueryRequest and receiving a response
        static void testQueryRequestClient()
        {
            Guid         myGuid    = Guid.NewGuid();
            TcpClient    tcpClient = new TcpClient("172.18.9.11", 7890);
            ClientThread ct        = new ClientThread(tcpClient, false, myGuid);
            QueryRequest qr        = new QueryRequest(IPAddress.Parse(Node.GetInternetAddress()), myGuid, 777);

            qr.QueryType = QueryType.Hostname;
            ct.EnqueueWork(qr);
            int x = 0;

            while (ct.EventCount() == 0)
            {
                x++;
                Thread.Sleep(1000);
                Print("waiting for response. " + x);
            }
            NetworkResponse response = (NetworkResponse)ct.DequeueEvent();

            Print("response: " + response.Type + " reason: " + response.Reason);
            ct.RequestStop();
            Print("requested stop");
            while (ct.IsAlive())
            {
                x++;
                Thread.Sleep(1000);
                Print("waiting for thread to die. " + x);
            }
            Print("thread dead.");
            Console.WriteLine("press a key to continue");
            Console.ReadKey();
        }
コード例 #6
0
        public MainForm(ClientThread manager)
        {
            this.Manager = manager;
            InitializeComponent();

            connectionStatus          = new System.Timers.Timer(1000);
            connectionStatus.Elapsed += Connection_Elapsed;

            onlineCheckTimer          = new System.Timers.Timer(5000);
            onlineCheckTimer.Elapsed += OnlineCheckTimer_Elapsed;

            ConfigManager = new Common.Config.Manager();

            Manager.ClientListener.OnHostInitalizeConnected += (object sender, Common.EventArgs.Network.Client.HostInitalizeConnectedEventArgs e) =>
            {
                Network.Messages.Connection.Request.HostConnectionMessage ms = new Network.Messages.Connection.Request.HostConnectionMessage();
                ms.HostSystemId   = e.HostSystemId;
                ms.ClientSystemId = e.ClientSystemId;
                ms.Password       = Manager.Manager.Encode(e.HostSystemId, this.txtPassword.Text);
                ms.SymmetricKey   = Manager.Manager.Encode(e.HostSystemId, Manager.Manager.getSymmetricKeyForRemoteId(e.HostSystemId));

                Manager.Manager.sendMessage(ms);
            };
            Manager.ClientListener.OnClientConnected += OnClientConnected;

            Manager.ClientListener.onNetworkError        += ClientListener_onNetworkError;
            Manager.ClientListener.onPeerConnected       += ClientListener_onPeerConnected;
            Manager.ClientListener.onPeerDisconnected    += ClientListener_onPeerDisconnected;
            Manager.ClientListener.OnOnlineCheckReceived += ClientListener_OnOnlineCheckReceived;

            Manager.Start();
        }
コード例 #7
0
        public int GetFreeNode(ClientThread clientThread)
        {
            int  Result = 0;
            bool Raise  = false;

            lock (_ListLock)
            {
                // Check for a free node
                for (int i = _NodeFirst; i <= _NodeLast; i++)
                {
                    if (_ClientThreads[i] == null)
                    {
                        clientThread.ErrorMessageEvent   += new EventHandler <StringEventArgs>(ClientThread_ErrorMessageEvent);
                        clientThread.ExceptionEvent      += new EventHandler <ExceptionEventArgs>(ClientThread_ExceptionEvent);
                        clientThread.LogOffEvent         += new EventHandler <NodeEventArgs>(ClientThread_LogOffEvent);
                        clientThread.LogOnEvent          += new EventHandler <NodeEventArgs>(ClientThread_LogOnEvent);
                        clientThread.NodeEvent           += new EventHandler <NodeEventArgs>(ClientThread_NodeEvent);
                        clientThread.WarningMessageEvent += new EventHandler <StringEventArgs>(ClientThread_WarningMessageEvent);
                        clientThread.WhoIsOnlineEvent    += new EventHandler <WhoIsOnlineEventArgs>(ClientThread_WhosOnlineEvent);
                        _ClientThreads[i] = clientThread;

                        Result = i;
                        Raise  = true;

                        break;
                    }
                }
            }

            if (Raise)
            {
                RaiseConnectionCountChangeEvent();
            }
            return(Result);
        }
コード例 #8
0
            private static void ClientThreadFunc(object data)
            {
                Console.WriteLine("Client thread started");
                ClientThread ct = data as ClientThread;

                ct.Run();
            }
コード例 #9
0
 private void Start()
 {
     /// 之後整合要移走: ON/OFF - line +開關條件
     ct = new ClientThread(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, "127.0.0.1", 5566);          //localhost
     ct.StartConnect();
     isSend = true;
 }
コード例 #10
0
        public static int GetFreeNode(ClientThread clientThread)
        {
            int  Result = 0;
            bool Raise  = false;

            if (clientThread != null)
            {
                lock (_ListLock) {
                    // Check for a free node
                    for (int i = Config.Instance.FirstNode; i <= Config.Instance.LastNode; i++)
                    {
                        if (_ClientThreads[i] == null)
                        {
                            clientThread.FinishEvent      += ClientThread_FinishEvent;
                            clientThread.NodeEvent        += ClientThread_NodeEvent;
                            clientThread.WhoIsOnlineEvent += ClientThread_WhosOnlineEvent;
                            _ClientThreads[i]              = clientThread;

                            Result = i;
                            Raise  = true;

                            break;
                        }
                    }
                }
            }

            if (Raise)
            {
                UpdateConnectionCount();
            }
            return(Result);
        }
コード例 #11
0
 private void Start()
 {
     // 39.9.131.193
     // 10.40.149.114
     ct = new ClientThread(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, "127.0.0.1", 8000);
     ct.StartConnect();
 }
コード例 #12
0
 IEnumerator RunClient()
 {
     UnityEngine.Debug.Log("starting client thread");
     _client = new ClientThread();
     _client.Start();
     yield return(null);
 }
コード例 #13
0
ファイル: Rules.cs プロジェクト: Gremlin13/StarryboundServer
        public Rules(ClientThread client)
        {
            this.name = "rules";
            this.HelpText = "Shows the list of all rules on the server.";

            this.client = client;
            this.player = client.playerData;
        }
コード例 #14
0
ファイル: Uptime.cs プロジェクト: Gremlin13/StarryboundServer
        public Uptime(ClientThread client)
        {
            this.name = "uptime";
            this.HelpText = ": Shows how long has past since the server was last restarted.";

            this.client = client;
            this.player = client.playerData;
        }
コード例 #15
0
        public WarpShip(ClientThread client)
        {
            this.name = "warpship";
            this.HelpText = " <name>: Teleports you to another player's ship.";

            this.client = client;
            this.player = client.playerData;
        }
コード例 #16
0
        private void StartClient()
        {
            ct = new ClientThread(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, "127.0.0.1", 12580);
            ct.StartConnect();

            //isSend = true;
            isWaitingForConnection = true;
        }
コード例 #17
0
        protected override void Execute()
        {
            using (_Server = new WebSocketConnection()) {
                if (_Server.Listen(_Address, _Port))
                {
                    RaiseListeningEvent();

                    while (!_Stop)
                    {
                        try {
                            // Accept an incoming connection
                            if (_Server.CanAccept(1000)) // 1 second
                            {
                                Socket NewSocket = _Server.Accept();
                                if (NewSocket != null)
                                {
                                    lock (_ClientThreadsLock) {
                                        WebSocketClientThread ClientThread = new WebSocketClientThread(NewSocket, ++_ClientThreadCounter);
                                        ClientThread.FinishEvent += ClientThread_FinishEvent;
                                        _ClientThreads.Add(ClientThread);
                                        RMLog.Info(_ClientThreads.Count.ToString() + " active connections");
                                        ClientThread.Start();
                                    }
                                }
                            }
                        } catch (Exception ex) {
                            RMLog.Exception(ex, "Unable to accept new websocket connection");
                        }
                    }

                    // Stop client threads
                    int ClientThreadCount = 0;
                    lock (_ClientThreadsLock) {
                        foreach (var ClientThread in _ClientThreads)
                        {
                            if (ClientThread != null)
                            {
                                ClientThread.Stop();
                            }
                        }
                        ClientThreadCount = _ClientThreads.Count;
                    }

                    // Wait for client threads
                    while (ClientThreadCount > 0)
                    {
                        lock (_ClientThreadsLock) {
                            ClientThreadCount = _ClientThreads.Count;
                        }
                        Thread.Sleep(100);
                    }
                }
                else
                {
                    RMLog.Error("WebSocket Server Thread: Unable to listen on " + _Address + ":" + _Port);
                }
            }
        }
コード例 #18
0
    private void Start()
    {
        ct = new ClientThread(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, "192.168.208.120", 9000);
        ct.StartConnect();
        isSend = true;
        var texture = new Texture2D(448, 252, TextureFormat.RGB24, false);

        rawImage.texture = texture;
    }
コード例 #19
0
        public Players(ClientThread client)
        {
            this.name = "players";
            this.HelpText = ": Lists all of the players connected to the server.";
            this.aliases = new string[] {"list","who"};

            this.client = client;
            this.player = client.playerData;
        }
コード例 #20
0
ファイル: Find.cs プロジェクト: Gremlin13/StarryboundServer
        public Find(ClientThread client)
        {
            this.name = "find";
            this.HelpText = " <player (optional)>; Find your world co-ordinates or those of a specified player.";
            this.aliases = new string[] { "where" };

            this.client = client;
            this.player = client.playerData;
        }
コード例 #21
0
        public RunDoorSBBSEXEC(ClientThread clientThread)
        {
            _ClientThread = clientThread;

            // Initialize filename variables
            EnvFile     = StringUtils.PathCombine(ProcessUtils.StartupPath, "node" + _ClientThread.NodeInfo.Node.ToString(), "dosxtrn.env");
            RetFile     = StringUtils.PathCombine(ProcessUtils.StartupPath, "node" + _ClientThread.NodeInfo.Node.ToString(), "dosxtrn.ret");
            W32DoorFile = StringUtils.PathCombine(ProcessUtils.StartupPath, "node" + _ClientThread.NodeInfo.Node.ToString(), "w32door.run");
        }
コード例 #22
0
ファイル: Build.cs プロジェクト: Gremlin13/StarryboundServer
        public Build(ClientThread client)
        {
            this.name = "build";
            this.HelpText = " <username>: Allows you to grant/revoke a player's building rights, this command is toggled.";
            this.Permission = new List<string>();
            this.Permission.Add("admin.build");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #23
0
ファイル: Planet.cs プロジェクト: Gremlin13/StarryboundServer
        public Planet(ClientThread client)
        {
            this.name = "planet";
            this.HelpText = ": Teleports you to the planet your ship is orbiting.";
            this.Permission = new List<string>();
            this.Permission.Add("client.planet");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #24
0
        public BanCommand(ClientThread client)
        {
            this.name = "ban";
            this.HelpText = " <username> <length (mins)> <reason>: Bans the user from the server for the specified time (in minutes) and reason.";
            this.Permission = new List<string>();
            this.Permission.Add("admin.ban");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #25
0
ファイル: Client.cs プロジェクト: s330528s/VolleyBall
    private void Start()
    {
        ss.a = 1;
        ss.b = 2;

        // ct = new ClientThread(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, "127.0.0.1", 8000);
        ct = new ClientThread(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, PlayerParam.ipAddress, 8000);
        ct.StartConnect();
        isSend = true;
    }
コード例 #26
0
        public Restart(ClientThread client)
        {
            this.name = "restart";
            this.HelpText = "Initiate a restart of the server, 30 second delay.";
            this.Permission = new List<string>();
            this.Permission.Add("admin.restart");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #27
0
        public Broadcast(ClientThread client)
        {
            this.name = "broadcast";
            this.HelpText = " <message>: Sends a server-wide message to all clients.";
            this.Permission = new List<string>();
            this.Permission.Add("admin.broadcast");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #28
0
        public Shutdown(ClientThread client)
        {
            this.name = "shutdown";
            this.HelpText = ": Gracefully closes all connections";
            this.Permission = new List<string>();
            this.Permission.Add("admin.shutdown");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #29
0
ファイル: Home.cs プロジェクト: Gremlin13/StarryboundServer
        public Home(ClientThread client)
        {
            this.name = "home";
            this.HelpText = ": Allows you to teleport to your home planet.";
            this.Permission = new List<string>();
            this.Permission.Add("client.home");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #30
0
        public MeCommand(ClientThread client)
        {
            this.name = "me";
            this.HelpText = " <message>: Sends an emote message.";
            this.Permission = new List<string>();
            this.Permission.Add("chat.emote");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #31
0
ファイル: Kick.cs プロジェクト: Gremlin13/StarryboundServer
        public Kick(ClientThread client)
        {
            this.name = "kick";
            this.HelpText = " <username>: Kicks the user from the server.";
            this.Permission = new List<string>();
            this.Permission.Add("admin.kick");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #32
0
ファイル: Mute.cs プロジェクト: Gremlin13/StarryboundServer
        public Mute(ClientThread client)
        {
            this.name = "mute";
            this.HelpText = " <username>: Allows you to mute/unmute a player, this command is toggled.";
            this.Permission = new List<string>();
            this.Permission.Add("admin.mute");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #33
0
        public WhosThereCommand(ClientThread client)
        {
            this.name = "whosthere";
            this.HelpText = ": shows a list of all players in this world.";

            this.Permission = new List<string>();
            this.Permission.Add("world.listplayers");

            this.player = client.playerData;
            this.client = client;
        }
コード例 #34
0
 private void Start()
 {
     theta_tar_a = new float[] { 0, 90, 0, 0, 0, 0, 0 };                                                        //[Caution!] the public var should initialize here!!! ; Gripper: theta_now_a[6], 1: close; 0: open
     /// 之後整合要移走: ON/OFF - line +開關條件
     ct = new ClientThread(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, "127.0.0.1", 5566); //localhost
     ct.StartConnect();
     isSend         = true;
     ctrl_tpad_flag = false;
     ctrl_grip_flag = false;
     devider        = 0;
 }
コード例 #35
0
        public ClientReceivingThread(ClientThread clientThread, ReceivingQManager receivingQManager)
        {
            this.clientThread      = clientThread;
            this.receivingQManager = receivingQManager;
            bRunFlag = true;

            ThreadStart threadStart = new ThreadStart(run);
            Thread      thread      = new Thread(threadStart);

            thread.Start();
        }
コード例 #36
0
ファイル: Ship.cs プロジェクト: Gremlin13/StarryboundServer
        public Ship(ClientThread client)
        {
            this.name = "ship";
            this.HelpText = ": Teleports you to your or another player's ship.";
            this.Permission = new List<string>();
            this.Permission.Add("client.ship");
            this.Permission.Add("e:admin.ship");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #37
0
ファイル: Item.cs プロジェクト: Gremlin13/StarryboundServer
        public Item(ClientThread client)
        {
            this.name = "item";
            this.HelpText = "<item> <amount>; Allows you to give items to yourself.";
            this.aliases = new string[] { "give" };
            this.Permission = new List<string>();
            this.Permission.Add("admin.give");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #38
0
        public GroupCommand(ClientThread client)
        {
            this.name = "group";
            this.HelpText = ": Allows you to manage permission groups. Type /group help for full instructions.";

            this.Permission = new List<string>();
            this.Permission.Add("admin.managegroups");

            this.player = client.playerData;
            this.client = client;
        }
コード例 #39
0
        public AdminChat(ClientThread client)
        {
            this.name = "admin";
            this.HelpText = "<message>: Sends a message to all online admins.";
            this.aliases = new string[] {"#<message>"};
            this.Permission = new List<string>();
            this.Permission.Add("chat.admin");
            this.Permission.Add("e:admin.chat");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #40
0
 private void Start()
 {
     KeyName.text = "kevin";
     KeyHost.text = "10.211.55.3:100";
     c_btn.onClick.AddListener(delegate
     {
         SetHost();
         _clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         ct            = new ClientThread(_clientSocket, KeyName.text, remoteEP);
         ct.StartConnect();
         ct.handlerString += ConnectFailed;
     });
 }
コード例 #41
0
        private int RaiseConnectEvent(ref ClientThread clientThread)
        {
            EventHandler <ConnectEventArgs> Handler = ConnectEvent;

            if (Handler != null)
            {
                ConnectEventArgs e = new ConnectEventArgs(clientThread);
                Handler(this, e);
                return(e.Node);
            }

            return(0);
        }
コード例 #42
0
 private void TcpListen()
 {
     while (!exitFlag)
     {
         try
         {
             var client    = server.Accept();
             var newClient = new ClientThread(client, callback);
             var newThread = new Thread(newClient.ClientService);
             newThread.Start();
         }
         catch { }
     }
 }
コード例 #43
0
            private async Task ApplyThreadRequest()
            {
                var clientThread = new ClientThread()
                {
                    Title    = Title,
                    Response = new ClientResponse()
                    {
                        Body = Body, Mail = Mail, Name = Name
                    }
                };
                var ip = IpManager.GetHostName(_connectionInfo, _headers);

                await clientThread.CreateThreadAsync(BoardKey, ip, _context, _dependency, _sessionManager.Session);
            }
コード例 #44
0
 public void DisplayActiveConnections()
 {
     lock (_ClientThreadsLock) {
         foreach (var ClientThread in _ClientThreads)
         {
             if (ClientThread != null)
             {
                 try {
                     ClientThread.DisplayConnectionInformation();
                 } catch (Exception ex) {
                     RMLog.Exception(ex, "Error listing client thread details");
                 }
             }
         }
     }
 }
コード例 #45
0
 public void Close()
 {
     ListenerUp = false;
     foreach (TcpClient thisClient in ClientTcpClients)
     {
         thisClient.Close();
     }
     foreach (Thread ClientThread in ClientThreads)
     {
         ClientThread.Interrupt();
     }
     Game.NetworkUp = false;
     DropIPV6UPNP();
     DropIPV4UPNP();
     Dispose();
 }
コード例 #46
0
 private static void TcpListen()
 {
     try
     {
         while (true)
         {
             System.Net.Sockets.Socket k = server.Accept();
             ClientThread @object        = new ClientThread(k);
             Thread       thread         = new Thread(new ThreadStart(@object.ClientService));
             thread.Start();
         }
     }
     catch
     {
     }
 }
コード例 #47
0
        static void Main(string[] args)
        {
            // process cmd line
            // -prs <PRS IP address>:<PRS port>

            // create the session table
            SessionTable sessionTable = new SessionTable();

            // get the listening port from the PRS for the "SD Server" service
            string serviceName = "SD Server";
            string prsIP       = "127.0.0.1";
            ushort prsPort     = 30000;

            PRSServiceClient.prsAddress = IPAddress.Parse(prsIP);
            PRSServiceClient.prsPort    = prsPort;
            PRSServiceClient prs           = new PRSServiceClient(serviceName);
            ushort           listeningPort = prs.RequestPort();

            // create the TCP listening socket
            Socket listeningSocket = new Socket(SocketType.Stream, ProtocolType.Tcp);

            listeningSocket.Bind(new IPEndPoint(IPAddress.Any, listeningPort));
            listeningSocket.Listen(42);     // 42 is the number of clients that can be waiting for us to accept their connection
            Console.WriteLine("Listening for clients on port " + listeningPort.ToString());

            bool done = false;

            while (!done)
            {
                // wait for a client to connect
                Console.WriteLine("Ready to accept new client");
                Socket clientSocket = listeningSocket.Accept();
                Console.WriteLine("Accepted connection from client");

                // create a thread for this client, and then return to listening for more clients
                Console.WriteLine("Launch new thread for connected client");
                ClientThread clientThread = new ClientThread(clientSocket, sessionTable);
                clientThread.Start();
            }

            // close down the listening socket
            Console.WriteLine("Closing listening socket");
            listeningSocket.Close();

            // close the listening port that I received from the PRS
            prs.ClosePort();
        }
コード例 #48
0
        public static void Run(ClientThread clientThread)
        {
            if (clientThread == null)
            {
                throw new ArgumentNullException("clientThread");
            }

            // Loop through the options, and run the ones we allow here
            bool ExitFor = false;

            string[] Processes = LogOnProcess.GetProcesses();
            for (int i = 0; i < Processes.Length; i++)
            {
                try {
                    LogOnProcess LP = new LogOnProcess(Processes[i]);
                    if ((LP.Loaded) && (!clientThread.QuitThread()))
                    {
                        switch (LP.Action)
                        {
                        case Action.Disconnect:
                        case Action.DisplayFile:
                        case Action.DisplayFileMore:
                        case Action.DisplayFilePause:
                        case Action.MainMenu:
                        case Action.Pause:
                        case Action.RunDoor:
                            MenuOption MO = new MenuOption("", '\0')
                            {
                                Action         = LP.Action,
                                Name           = LP.Name,
                                Parameters     = LP.Parameters,
                                RequiredAccess = LP.RequiredAccess,
                            };
                            ExitFor = clientThread.HandleMenuOption(MO);
                            break;
                        }
                        if (ExitFor)
                        {
                            break;
                        }
                    }
                } catch (Exception ex) {
                    // If there's something wrong with the ini entry (Action is invalid for example), this will throw a System.ArgumentException error, so we just ignore that menu item
                    RMLog.Exception(ex, "Error during logon process '" + Processes[i] + "'");
                }
            }
        }
コード例 #49
0
        public void start()
        {
            server = new TcpListener(IPAddress.Parse("127.0.0.1"), port);

            server.Start();
            System.Console.WriteLine("Server started.");

            while (true)
            {
                client_socket = server.AcceptTcpClient();
                System.Console.WriteLine("Client connected.");
                stream = client_socket.GetStream();

                ClientThread client = new ClientThread(stream, this);
                al.Add(client);
            }
        }
コード例 #50
0
 /// <summary>
 /// Start the client process and connect it with the server.
 /// </summary>
 /// <param name="tcpclient"></param>
 private void connectionEvent(TcpClient tcpclient)
 {
     process = new ClientThread(tcpclient);
     process.messageHandler      = new UserThread.newMessageHandler(handleMessage);
     process.loginHandler        = new UserThread.newLoginHandler(loginHandler);
     process.challengerHandler   = new UserThread.newChallengerHandler(challengerHandler);
     process.connectionHandler   = new ClientThread.newConnectionHandler(connectionHandler);
     process.deconnectionHandler = new UserThread.newDeconnectionHandler(deconnectionHandler);
     process.endGameHandler      = new UserThread.newEndGameHandler(endGameHandler);
     process.stopGameHandler     = new UserThread.newStopGameHandler(stopGameHandler);
     process.userListHandler     = new ClientThread.newUserListHandler(userListHandler);
     process.clearHandler        = new ClientThread.newClearHandler(clearHandler);
     process.startGameHandler    = new ClientThread.newStartGameHandler(startGameHandler);
     process.receiveMsgHandler   = new ClientThread.newReceiveHandler(receiveMsgHandler);
     process.gameHandler         = new ClientThread.newGameHandler(gameHandler);
     process.start();
 }
コード例 #51
0
ファイル: ClientsManager.cs プロジェクト: nhinze/rhodes
            public void registerClient(string clientGuid)
            {
                Logger.Write("[manager] register new client: " + clientGuid);

                if (m_clients != null && !m_clients.ContainsKey(clientGuid))
                {
                    Logger.Write("start register [manager]: " + clientGuid);

                    ClientThread newClient = new ClientThread(clientGuid, m_applicationForm);

                    newClient.startThread();
                    m_clients.Add(clientGuid, newClient);
                }
                else
                {
                    Logger.Write("[manager] register new client repeatedly");
                }
            }
コード例 #52
0
ファイル: ClientsManager.cs プロジェクト: rhomobile/rhodes
        public void registerClient(string clientGuid)
        {
            Logger.Write("[manager] register new client: " + clientGuid);

            if (m_clients != null && !m_clients.ContainsKey(clientGuid))
            {
                Logger.Write("start register [manager]: " + clientGuid);

                ClientThread newClient = new ClientThread(clientGuid, m_applicationForm);
                
                newClient.startThread();
                m_clients.Add(clientGuid, newClient);
            }
            else
            {
                Logger.Write("[manager] register new client repeatedly");
            }
        }
コード例 #53
0
		private void AcceptThreadRun()
		{
			while (true)
			{
				try
				{
					System.Net.Sockets.TcpClient clientSock = serverSocket.AcceptTcpClient();
					
					ClientThread client = new ClientThread(this, clientSock);
					client.Start();
					
					lock (clients)
					{
						clients.Add(client);
					}
				}
				catch (IOException)
				{
				}
			}
		}
コード例 #54
0
 public Packet11ChatSend(ClientThread clientThread, Object stream, Direction direction)
 {
     this.mClient = clientThread;
     this.mStream = stream;
     this.mDirection = direction;
 }
コード例 #55
0
ファイル: Server.cs プロジェクト: qq5013/XJ_WCS
 private void Listen()
 {
     this.server.Listen(10);
     while (this.isRun)
     {
         Socket client = this.server.Accept();
         client.Blocking = true;
         ClientThread thread = new ClientThread(this, client);
         thread.OnReceive += this.OnReceive;
         thread.OnDisconnect += this.OnDisconnect;
         this.clients.Clear();
         this.clients.Add(thread);
         if (this.OnConnect != null)
         {
             this.OnConnect(this, new SocketEventArgs(client));
         }
         thread.Start();
     }
 }
コード例 #56
0
 public Packet2ConnectResponse(ClientThread clientThread, Object stream, Direction direction)
 {
     this.mClient = clientThread;
     this.mStream = stream;
     this.mDirection = direction;
 }
コード例 #57
0
        public BanReloadCommand(ClientThread client)
        {
            this.name = "banreload";
            this.HelpText = ": Reloads the banned-players.txt file";
            this.Permission = new List<string>();
            this.Permission.Add("admin.reload");

            this.client = client;
            this.player = client.playerData;
        }
コード例 #58
0
ファイル: Server.cs プロジェクト: qq5013/XJ_WCS
 internal void RemoveClient(ClientThread client)
 {
     this.clients.Remove(client);
 }
コード例 #59
0
    static public void Main(string[] args)
    {    
        Storage storage = StorageFactory.Instance.CreateStorage();
        storage.Open(new NullFile(), 0);
        Database db = new Database(storage, true);

        DateTime start = DateTime.Now;
        Thread[] threads = new Thread[nThreads];
        for (int i = 0; i < nThreads; i++) 
        {
            ClientThread client = new ClientThread(db, i);  
            threads[i] = new Thread(new ThreadStart(client.run));
            threads[i].Start();
        }
#if !COMPACT_NET_FRAMEWORK
        for (int i = 0; i < nThreads; i++) 
        { 
            threads[i].Join();
        }
        storage.Close();
#endif
        Console.WriteLine("Elapsed time: " + (DateTime.Now - start));
    }
コード例 #60
0
 public Packet5ChatReceive(ClientThread clientThread, Object stream, Direction direction)
 {
     this.mClient = clientThread;
     this.mStream = stream;
     this.mDirection = direction;
 }