Esempio n. 1
0
        private void InitSocket()
        {
            try
            {
                tbxLocalIpAddress.Text =
                    Regex.Replace(tbxLocalIpAddress.Text, @"[^0-9].[^0-9].[^0-9].[^0-9]", "");
                tbxPort.Text = Regex.Replace(tbxPort.Text, @"[^0-9]", "");
                if (tbxLocalIpAddress.Text == "" || tbxPort.Text == "")
                {
                    MessageBox.Show("Local IP Address 또는 Port 번호가 올바르지 않습니다.");
                    throw new Exception();
                }
                TcpListner = new TcpListener(IPAddress.Parse(tbxLocalIpAddress.Text.Trim()), Int32.Parse(tbxPort.Text));
                TcpClient  = default(TcpClient);
                TcpListner.Start();
                DisplayText(">> server Started");
                while (true)
                {
                    try
                    {
                        TcpClient = TcpListner.AcceptTcpClient();

                        NetworkStream stream  = TcpClient.GetStream();
                        byte[]        buffer  = new byte[1024];
                        int           bytes   = stream.Read(buffer, 0, buffer.Length);
                        string        channel = Encoding.Unicode.GetString(buffer, 0, bytes);
                        channel = channel.Split('$')[0];

                        this.Invoke(new DeligateGetClientIP(GetClientIP), channel);

                        ClientList.Add(TcpClient, channel);

                        IpPoint  = (IPEndPoint)TcpClient.Client.RemoteEndPoint;
                        ClientIP = IpPoint.Address + ":" + IpPoint.Port;
                        ClientInfoList.Add(ClientIP.ToString());
                        SendMessageAll(ClientIP + "/ 님이 연결되었습니다.", channel, false);

                        HandleClient handle = new HandleClient();
                        handle.OnReceived     += new HandleClient.MessageDisplayHandler(OnReceived);
                        handle.OnDisconnected += new HandleClient.DisconnectedHandler(HandlerClientsOnDisconnected);
                        handle.StartClient(TcpClient, ClientList);
                    }
                    catch
                    {
                        throw new SocketException();
                    }
                }
            }
            catch (SocketException ex)
            {
                this.Invoke(new DeligateDisconnect(Disconnect));
            }
            catch (Exception ex)
            { }
            finally
            {
                this.Invoke(new DeligateButtonChange(ButtonStatusChange));
            }
        }
        public override void displayPlayer(PlayerInfo _pInfo)
        {
            string output = "";

            output += new ClientInfoList(_pInfo, _options).DisplayShortWithPos();

            SendOutput(output);
        }
Esempio n. 3
0
        public override void displayPlayer(PlayerInfo _pInfo)
        {
            string output = "";

            output += new ClientInfoList(_pInfo, _options).DisplayShort(_sep);
            output += _sep;
            output += new SkillList(_pInfo, _options).Display(_sep);

            SendOutput(output);
        }
Esempio n. 4
0
        public virtual void displayPlayer(PlayerInfo _pInfo)
        {
            string output = "";

            output += new ClientInfoList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new StatsList(_pInfo, _options).Display(_sep);

            SendOutput(output);
        }
Esempio n. 5
0
        private void OnReceived(string message, string channel)
        {
            try
            {
                ClientIP    = message.Split('/')[0];
                Sendmessage = message.Substring(message.IndexOf("/") + 1);
                string displayMessage = ClientIP + "/" + channel + ">" + Sendmessage;
                DisplayText(displayMessage);
                SendMessageAll(message, channel, true);

                if (Sendmessage == " 연결을 해제합니다.")
                {
                    ClientInfoList.Remove(ClientIP);
                }
            }
            catch (Exception ex) { }
        }
Esempio n. 6
0
        public void ButtonStatusChange()
        {
            try
            {
                btnStart.Enabled = !(btnStart.Enabled);
                btnStop.Enabled  = !(btnStop.Enabled);


                if (btnStart.Enabled == true && ClientIP != null)
                {
                    foreach (string clientInfo in ClientInfoList)
                    {
                        rtbxReceivedData.Text += clientInfo + " 와의 연결이 끊어졌습니다.\r\n";
                    }
                    ClientInfoList.Clear();
                }
            }
            catch (Exception ex) { }
        }
Esempio n. 7
0
        private void OnReceived(string message, string channel, bool isClientClose)
        {
            try
            {
                ClientIP    = message.Split('/')[0];
                Sendmessage = message.Substring(message.IndexOf("/") + 1);
                string displayMessage = ClientIP + "/" + channel + ">" + Sendmessage;
                DisplayText(displayMessage);
                SendMessageAll(message, channel, false);

                if (isClientClose)
                {
                    ClientInfoList.Remove(ClientIP);
                }
            }
            catch (Exception ex)
            {
                ServerEvent.ErrorLog("OnReceived", ex.Message);
            }
        }
Esempio n. 8
0
        public override void displayPlayer(PlayerInfo _pInfo)
        {
            string output = "";

            output += new ClientInfoList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new StatsList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new BuffList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new SkillList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new QuestList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new SpawnpointList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new WaypointList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new FavoriteRecipeList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new UnlockedRecipeList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new CraftingQueue(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new ToolbeltList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new EquipmentList(_pInfo, _options).Display(_sep);
            output += _sep;
            output += new BagList(_pInfo, _options).Display(_sep);
            output += _sep;

            // todo:
            // friends
            // tracked friends // _pdf.trackedFriendEntityIds //List<int>
            // claims (_ppd.LPBlocks)
            // list owned storage containers and doors for the players

            SendOutput(output);
        }
Esempio n. 9
0
        public void ButtonStatusChange()
        {
            try
            {
                btnStart.Enabled = !(btnStart.Enabled);
                btnStop.Enabled  = !(btnStop.Enabled);


                if (btnStart.Enabled == true && ClientIP != null)
                {
                    foreach (string clientInfo in ClientInfoList)
                    {
                        DisplayText(clientInfo + " 와의 연결이 끊어졌습니다.");
                    }
                    ClientInfoList.Clear();
                }
            }
            catch (Exception ex)
            {
                ServerEvent.ErrorLog("ButtonStatusChange", ex.Message);
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     this.ThisWebPart = this.Parent as SearchClient;
     clients = Production.Business.ClientInfoList.GetList();
 }
Esempio n. 11
0
        private void InitSocket()
        {
            try
            {
                tbxLocalIpAddress.Text =
                    Regex.Replace(tbxLocalIpAddress.Text, @"[^0-9].[^0-9].[^0-9].[^0-9]", "");
                tbxPort.Text = Regex.Replace(tbxPort.Text, @"[^0-9]", "");
                if (tbxLocalIpAddress.Text == "" || tbxPort.Text == "")
                {
                    MessageBox.Show("Local IP Address 또는 Port 번호가 올바르지 않습니다.");
                    throw new Exception();
                }
                TcpListner = new TcpListener(IPAddress.Parse(tbxLocalIpAddress.Text.Trim()), Int32.Parse(tbxPort.Text));
                TcpClient  = default(TcpClient);
                TcpListner.Start();
                DisplayText(">> server Started");
                while (true)
                {
                    try
                    {
                        TcpClient = TcpListner.AcceptTcpClient();

                        NetworkStream stream = TcpClient.GetStream();

                        stream = TcpClient.GetStream();//acc.Receive(sizeBuf, 0, sizeBuf.Length, 0);

                        byte[] sizeBuf = new byte[TcpClient.ReceiveBufferSize];
                        stream.Read(sizeBuf, 0, (int)TcpClient.ReceiveBufferSize);
                        int size = BitConverter.ToInt32(sizeBuf, 0);

                        MemoryStream ms = new MemoryStream();

                        while (size > 0)
                        {
                            byte[] buffer;
                            if (size < TcpClient.ReceiveBufferSize) //acc.ReceiveBufferSize)
                            {
                                buffer = new byte[size];
                            }
                            else
                            {
                                buffer = new byte[TcpClient.ReceiveBufferSize];
                            }

                            int rec = stream.Read(buffer, 0, buffer.Length);

                            size -= rec;
                            ms.Write(buffer, 0, buffer.Length);
                        }
                        ms.Close();

                        byte[] data = ms.ToArray();

                        ms.Dispose();

                        string channel = Encoding.UTF8.GetString(data);


                        this.Invoke(new DeligateGetClientIP(GetClientIP), channel);

                        ClientList.Add(TcpClient, channel);

                        IpPoint  = (IPEndPoint)TcpClient.Client.RemoteEndPoint;
                        ClientIP = IpPoint.Address + ":" + IpPoint.Port;
                        ClientInfoList.Add(ClientIP.ToString());

                        SendMessageAll(ClientIP + "/ 님이 연결되었습니다.", channel, true);

                        HandleClient handle = new HandleClient();
                        handle.OnReceived     += new HandleClient.MessageDisplayHandler(OnReceived);
                        handle.OnDisconnected += new HandleClient.DisconnectedHandler(HandlerClientsOnDisconnected);
                        handle.StartClient(TcpClient, ClientList);
                    }
                    catch
                    {
                        throw new SocketException();
                    }
                }
            }
            catch (SocketException ex)
            {
                this.Invoke(new DeligateDisconnect(Disconnect));
                ServerEvent.ErrorLog("InitSocket", ex.Message);
            }
            catch (Exception ex)
            {
                ServerEvent.ErrorLog("InitSocket", ex.Message);
            }
            finally
            {
                this.Invoke(new DeligateButtonChange(ButtonStatusChange));
            }
        }