Ejemplo n.º 1
0
 public FormClientUDP()
 {
     InitializeComponent();
     clientUDP = new ClientUDP();
     Ip        = string.Empty;
     Port      = 0;
 }
Ejemplo n.º 2
0
        public void StartUp()
        {
            if (IsRunning)
            {
                return;
            }

            IsRunning = false;

            try
            {
                ServerList.Init();

                UploadBandwidthThrottler.Start();

                DownloadQueue.Init();

                ListenSocket.StartListening();

                ClientUDP.Create();

                if (Preference.DoesAutoConnect)
                {
                    StartConnection();
                }

                IsRunning = true;
            }
            catch (Exception ex)
            {
                MpdUtilities.DebugLogError("MuleApplication StartUp Fail",
                                           ex);
            }
        }
Ejemplo n.º 3
0
        public void startCom()
        {
            Console.WriteLine("adresse serveur: ");
            string adresseServeur = "127.0.0.1";// Console.ReadLine();
            Console.WriteLine("port serveur: ");
            string portServeur = "11001";// Console.ReadLine();
            Console.WriteLine("adresse client: ");
            string adresseClient = "127.0.0.1";//Console.ReadLine();
            Console.WriteLine("port client: ");
            string portClient = "11000";//Console.ReadLine();

            /*******************/
            ClientUDP c = new ClientUDP(adresseClient, int.Parse(portClient), adresseServeur, int.Parse(portServeur));
            c.NomDeLaMethodePrincipale = loop1;
            Console.WriteLine("Connexion : {0}", c.Connexion());
            if (c.EstConnecte)
            {
                c.ExecuterMethodePrincipale();
            }

            //Console.WriteLine("Press a key to deconnect client");
            //Console.Read();
            //c.Deconnexion();
            //c2.Deconnexion();
        }
Ejemplo n.º 4
0
 void Awake()
 {
     Instance          = this;
     Screen.fullScreen = false;
     DontDestroyOnLoad(this.gameObject);
     ClientTcp.StartThread();
     ClientUDP.StartThread();
 }
Ejemplo n.º 5
0
        public void ConnectToServer()
        {
            Tcp = new ClientTCP();
            Udp = new ClientUDP();

            isConnected = true;
            Instance.Tcp.Connect();
        }
Ejemplo n.º 6
0
 public void Main()
 {
     for (var i = 0; i < 10000; i++)
     {
         var    clientRequestHandler = new ClientUDP();
         byte[] envio    = System.Text.ASCIIEncoding.ASCII.GetBytes(i + "*2+1");
         var    mensagem = clientRequestHandler.sendReceive(envio);
         //Console.WriteLine(System.Text.ASCIIEncoding.ASCII.GetString(mensagem));
     }
 }
Ejemplo n.º 7
0
        public void onLoginClick(Button button)
        {
            Console.WriteLine("Client: Login Attempt");
            //Console.WriteLine("User: "******"Password: "******"LoginAttemp", username + ":" + Utility.GerarHashMd5(password));
            ClientUDP.sendMessage("LoginAttempt", username + ":" + Utility.GerarHashMd5(password));
        }
Ejemplo n.º 8
0
    //关闭服务
    private void OnApplicationQuit()
    {
        print("OnApplicationQuit");
        if (SceneFlag == 1)
        {
            PlayerInfo.Instance.SendPlayerInfo();
            GManager.Instance.SendMessageByTcp("E1 " + UIManager.account + " ");
            GManager.Instance.SendMessageByUdp("E1 " + UIManager.account + " ");
        }

        ClientTcp.Close();
        ClientUDP.Close();
    }
Ejemplo n.º 9
0
 void Start()
 {
     if (singleton != null)
     {
         //alread have a clientUDP...
         Destroy(gameObject);
     }
     else
     {
         singleton = this;
         DontDestroyOnLoad(gameObject);
         ListenForPackets();
     }
 }
Ejemplo n.º 10
0
 public TestNet(string key)
 {
     this.key = key;
     if (key == "TCP")
     {
         serverTCP = new ServerTCP();
         clientTCP = new ClientTCP();
     }
     else if (key == "UDP")
     {
         clientUDP = new ClientUDP();
         ServerUDP = new ServerUDP();
     }
 }
Ejemplo n.º 11
0
 void Start()
 {
     if (singleton != null)
     {
         //already have a clientUDP...
         Destroy(gameObject);
     }
     else
     {
         singleton = this;
         DontDestroyOnLoad(gameObject);
         //set up receive loop (async)
         ListenForPackets();
     }
 }
Ejemplo n.º 12
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();

            Window.AllowUserResizing = true;
            ClientUDP.ReceiveMessages();

            // create our Scene with the DefaultRenderer and a clear color of CornflowerBlue
            //var loginScene = new LoginScene();
            var loginScene = new LoginScene();

            // set the scene so Nez can take over
            scene = loginScene;
        }
Ejemplo n.º 13
0
    void Start()
    {
        ListenForPackets();

        if (singleton != null)
        {
            Destroy(gameObject);
        }
        else
        {
            singleton = this;

            Buffer packet = Buffer.From("JOIN");
            SendPacket(packet);
        }
    }
Ejemplo n.º 14
0
    /// <summary>
    /// Most recent ball update packet
    /// that has been received...
    /// </summary>
    //uint ackBallUpdate = 0;

    void Start()
    {
        chatController.gameObject.SetActive(false);
        if (singleton != null)
        {
            // already have a clientUDP...
            Destroy(gameObject);
        }
        else
        {
            cam       = Camera.main;
            singleton = this;
            DontDestroyOnLoad(gameObject);
            ListenForPackets();
        }
    }
Ejemplo n.º 15
0
 void Start()
 {
     if (singleton != null)
     {
         //already have a clientUDP...
         Destroy(gameObject);
     }
     else
     {
         singleton = this;
         //set up receive loop (async)
         ListenForPackets();
         //send a packet to the server(async);
         SendPacket(Buffer.From("JOIN"));
     }
 }
Ejemplo n.º 16
0
    private void Update()
    {
        // Iterate through this when sending the Meshes (pieces of info)
        List <MeshList> listOfMeshList = new List <MeshList>();
        MeshList        sendList       = new MeshList();

        // Send upon keydown
        if (Input.GetKeyDown(KeyCode.Space))
        {
            AddToList(sendList, listOfMeshList);
            foreach (MeshList list in listOfMeshList)
            {
                ClientUDP <MeshList> .UDPSend(1234, list);
            }
        }
    }
Ejemplo n.º 17
0
        public override void Load()
        {
            if (!Main.dedServ)
            {
                clientTCP = new ClientTCP(this);
                clientTCP.OpenConnection(hostAddress, port);

                clientUDP = new ClientUDP(this);
                clientUDP.OpenSocket(hostAddress, 5000);
            }

            if (referenceDictionary == null)
            {
                //referenceDictionary = new Dictionary<string, Delegate>();
                //referenceDictionary.Add("Player.Position", (x, y) => {DelegateManager.SendPlayerPosition();});
            }
        }
Ejemplo n.º 18
0
    // callback for Async beginAccept
    private void OnConnect(IAsyncResult asyncResult)
    {
        UdpState udpState = (UdpState)asyncResult.AsyncState;

        UdpClient  udpClient = udpState.udpClient;
        IPEndPoint endPoint  = udpState.endPoint;

        byte[] message = udpClient.EndReceive(asyncResult, ref endPoint);
        Debug.Log("client connected");

        clientPort++;

        IClient client = new ClientUDP(endPoint, clientPort);

        NotifyNewClientConnected(client);

        // Signal the thread to continue.
        block.Set();
    }
Ejemplo n.º 19
0
    void Start()
    {
        ListenForPackets();

        if (singleton != null)
        {
            Destroy(gameObject);
        }
        else
        {
            singleton = this;
            DontDestroyOnLoad(gameObject);

            ListenForPackets();

            // Buffer packet = ConnectToServer();
            // SendPacket(packet);
        }
    }
Ejemplo n.º 20
0
    void Start()
    {
        ListenForPackets();

        if (singleton != null)
        {
            Destroy(gameObject);
        }
        else
        {
            singleton = this;
            DontDestroyOnLoad(gameObject);

            IPEndPoint ep = new IPEndPoint(IPAddress.Parse(serverHOST), serverPORT);
            sock = new UdpClient(ep.AddressFamily);
            sock.Connect(ep);

            ListenForPackets();

            Buffer packet = Buffer.From("JOIN");
            SendPacket(packet);
        }
    }
        public override void Initialize()
        {
            base.Initialize();

            Mod = GetInstance <TManagerAgent>();

            // Initialize connection to tOverseer
            ClientTCP = new ClientTCP(Mod.OverseerAddress, Mod.OverseerTCPPort);
            ClientTCP.OnMessageReceived += ParseServerMessage;
            bool success = ClientTCP.TryConnect();

            if (success)
            {
                ClientTCP.StartListening();
                ClientTCP.SendMessage("Terraria greets you via TCP.");
            }


            ClientUDP = new ClientUDP(Mod.OverseerAddress, Mod.OverseerUDPPort);
            ClientUDP.OnMessageReceived += ParseServerUDPMessage;
            ClientUDP.Connect();
            ClientUDP.StartListening();
            ClientUDP.SendMessage("Terraria greets you via UDP.");
        }
Ejemplo n.º 22
0
    private void Update()
    {
        // This is for first movement in the sequence
        if (Input.GetKeyDown(KeyCode.A))
        {
            testList.PList[4].Rotation = -45;
            testList.PList[5].Rotation = -45;
            testList.PList[8].Rotation = 90;
            testList.PList[9].Rotation = 90;
            ObjectJoint.SetJoints(testList, GameObject.Find("Sphere"));
        }

        // This is for the second movement in the sequence (repeate this and 3)
        if (Input.GetKeyDown(KeyCode.S))
        {
            testList.PList[4].Rotation = 45;
            testList.PList[5].Rotation = 45;
            testList.PList[8].Rotation = -90;
            testList.PList[9].Rotation = -90;

            testList.PList[2].Rotation = -45;
            testList.PList[3].Rotation = -45;
            testList.PList[6].Rotation = 90;
            testList.PList[7].Rotation = 90;

            ObjectJoint.SetJoints(testList, GameObject.Find("Sphere"));
        }

        // Third movement in the sequence
        if (Input.GetKeyDown(KeyCode.D))
        {
            testList.PList[4].Rotation = -45;
            testList.PList[5].Rotation = -45;
            testList.PList[8].Rotation = 90;
            testList.PList[9].Rotation = 90;

            testList.PList[2].Rotation = 45;
            testList.PList[3].Rotation = 45;
            testList.PList[6].Rotation = -90;
            testList.PList[7].Rotation = -90;

            GameObject root = GameObject.Find("Sphere");
            root.transform.Translate(Vector3.left * Time.deltaTime * 100);
            ObjectJoint.SetJoints(testList, GameObject.Find("Sphere"));
        }


#if ServerTesting
        // Configuring the robot with server test
        if (Input.GetKeyDown(KeyCode.A))
        {
            RobotStructure test = ClientUDP <RobotStructure> .UDPSend(8888, testStructure);

            ConstructionManager.GenerateRobot(test);
            ObjectJoint.GetJoints(GameObject.Find("Sphere").GetComponent <ObjectJoint>().ChildObjectJoints, GameObject.Find("Sphere"));
        }

        // Moving the thing
        if (Input.GetKeyDown(KeyCode.Space))
        {
            PositionListCreator.CreateList(GameObject.Find("Sphere"), testList.PList);
            PositionList newList = ClientUDP <PositionList> .UDPSend(7777, testList);

            ObjectJoint.SetJoints(newList, GameObject.Find("Sphere"));
        }
#endif
    }
Ejemplo n.º 23
0
 public void SendMessageByUdp(string msg)
 {
     ClientUDP.SendMsg(msg);
 }
Ejemplo n.º 24
0
        public void Stop()
        {
            try
            {
                CloseConnection();
            }
            catch (Exception ex)
            {
                MpdUtilities.DebugLogError("MuleApplication Stop Fail",
                                           ex);
            }

            try
            {
                ServerConnect.Stop();
            }
            catch (Exception ex)
            {
                MpdUtilities.DebugLogError("MuleApplication Stop Fail",
                                           ex);
            }

            try
            {
                ClientUDP.Close();
            }
            catch (Exception ex)
            {
                MpdUtilities.DebugLogError("MuleApplication Stop Fail",
                                           ex);
            }

            try
            {
                ListenSocket.StopListening();
            }
            catch (Exception ex)
            {
                MpdUtilities.DebugLogError("MuleApplication Stop Fail",
                                           ex);
            }

            try
            {
                LastCommonRouteFinder.StopFinder();
            }
            catch (Exception ex)
            {
                MpdUtilities.DebugLogError("MuleApplication Stop Fail",
                                           ex);
            }

            try
            {
                UploadBandwidthThrottler.Stop();
            }
            catch (Exception ex)
            {
                MpdUtilities.DebugLogError("MuleApplication Stop Fail",
                                           ex);
            }

            try
            {
                Preference.Save();
            }
            catch (Exception ex)
            {
                MpdUtilities.DebugLogError("MuleApplication Stop Fail",
                                           ex);
            }

            try
            {
                ClientCredits.CleanUp();
            }
            catch (Exception ex)
            {
                MpdUtilities.DebugLogError("MuleApplication Stop Fail",
                                           ex);
            }

            if (ShutDownMuleApplication != null)
            {
                ShutDownMuleApplication(this, new EventArgs());
            }
        }