Beispiel #1
0
 public void createSocket(ClientTerminal c)
 {
     string szIPSelected = ServerHost2.Text;
     string szPort = txtPort2.Text;
     int alPort = Convert.ToInt16(szPort, 10);
     IPAddress remoteIPAddress = IPAddress.Parse(szIPSelected);
     c.createSocket(remoteIPAddress, alPort);
 }
Beispiel #2
0
        public void connect2Server(ClientTerminal s)
        {
            try
            {
                // toSever.Connect(remoteIPAddress, alPort);
                s.Connect();
            }
            catch (SocketException se)
            {
                MessageBox.Show(se.Message);
                System.Environment.Exit(0);
            }

        }
Beispiel #3
0
        public void sendMsgToServer(byte[] bytes, Fleck.IWebSocketConnection clientSock, GlobalMessage msgType)
        {
            Socket value = null;
            if (msgType.Equals(GlobalMessage.PACKETERROR))
            {
                closeClient(clientSock);
                return;
            }
            else if (msgType == GlobalMessage.LOGIN)
            {
                ClientTerminal c = new ClientTerminal();
                c.Connected += new TCPTerminal_ConnectDel(ServerConnected);
                c.MessageRecived += new TCPTerminal_MessageRecivedDel(ServerMessageRecived);
                c.Disconncted += new TCPTerminal_DisconnectDel(ServerConnectionDroped);
                //clientTerminal = c;

                createSocket(c);
                value = c.m_socClient;
                toServer.Add(value, c);

                myGlobals.ClientServer.Add(clientSock, value);
                myGlobals.ServerClient.Add(value, clientSock);
                connect2Server(c);

            }
            else
                value = myGlobals.ClientServer[clientSock];

            //if (clientMsgProcess.messageType == clientMsgType.KEEPALIVEACK)
            //    clientHeartbeats[key].keepalive();

            toServer[value].SendMessage(bytes);
        }