Example #1
0
 public void EndConnections()
 {
     if (client != null)
     {
         client.Disconnect();
         client = null;
     }
     if (server != null)
     {
         server.Disconnect();
         server = null;
     }
 }
Example #2
0
        public ClientConnection(int ID, Socket socket, VmServer server)
        {
            this.ID     = ID;
            this.socket = socket;
            this.server = server;
            if (debugClientConnection)
            {
                Debug.Log("ClientConnection.ClientConnection (" + Thread.CurrentThread.ManagedThreadId + "): "
                          + "Client " + ID + " has connected");
            }

            VmSocketState socketState = new VmSocketState(this);

            socket.BeginReceive(socketState.buffer, 0, VmNetworking.BUFFER_LENGTH, SocketFlags.None, OnReceiveFromClient, socketState);
        }
Example #3
0
        public void StartConnections(World world)
        {
            if (!isServer)
            {
                //string[] ipSplit = serverIPAdress.Split('.');
                //if (ipSplit.Length < 4)
                //{
                //    Debug.LogError("ip must be 4 period separated integers");
                //    return;
                //}

                //byte[] ipComponents = new byte[4];
                //for (int i = 0; i < 4; i++)
                //{
                //    ipComponents[i] = byte.Parse(ipSplit[i]);
                //}
                //serverIP = new IPAddress(ipComponents);
                client = new VmClient(world, serverIP);
            }
            else if (allowConnections)
            {
                server = new VmServer(world);
            }
        }