Exemple #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            con = new TCP_Client <Client>();

            listBox1.DataSource = con.otherClients;
            con.Connect();
        }
        /// <summary>
        /// Starts flow processing.
        /// </summary>
        internal void Start()
        {
            // Move processing to thread pool.
            AutoResetEvent startLock = new AutoResetEvent(false);

            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object state){
                lock (m_pLock){
                    startLock.Set();

                    // TCP / TLS client, connect to remote end point.
                    if (!m_IsServer && m_Transport != SIP_Transport.UDP)
                    {
                        try{
                            TCP_Client client = new TCP_Client();
                            client.Connect(m_pLocalEP, m_pRemoteEP, m_Transport == SIP_Transport.TLS);

                            m_pTcpSession = client;

                            BeginReadHeader();
                        }
                        catch {
                            Dispose();
                        }
                    }
                }
            }));
            startLock.WaitOne();
            startLock.Close();
        }
    public void uploadMap(Text FileName)
    {
        int fileSize;

        uploadMapName = FileName.text;

        Debug.Log("Upload " + uploadMapName);

        Zip(uploadMapName);

        bool connectSuccess = false;

        tcpClient      = new TCP_Client(serverIP, serverPort);
        connectSuccess = tcpClient.ClientConnect();

        if (!connectSuccess)
        {
            return;
        }

        tcpClient.WriteString("Upload " + uploadMapName);

        fileSize = tcpClient.SendFile(Application.persistentDataPath + "/" + uploadMapName + ".zip");

        tcpClient.CloseClient();

        //debugFileSizeText.text = fileSize.ToString();

        //System.Diagnostics.Process.Start(Application.persistentDataPath);
    }
Exemple #4
0
 // Start is called before the first frame update
 void Start()
 {
     msg = new TCPmsg();
     Input.gyro.enabled = true;
     client             = GameObject.Find("NetworkManager").GetComponent <TCP_Client>();
     Accelerometer_text = GameObject.Find("Accelerometer").GetComponent <Text>();
     Gyroscope_text     = GameObject.Find("Gyroscope").GetComponent <Text>();
 }
 public Server(string host, string userName, SecureString password)
 {
     this.m_pClient           = new TCP_Client();
     this.m_pLockSynchronizer = this.m_pClient;
     this.m_Host     = host;
     this.m_UserName = userName;
     this.Password   = password;
 }
Exemple #6
0
 public static void Run()
 {
     while (runThread)
     {
         TCP_Client.StartClient();
         runThread = false;
     }
     // connection lost - restart thread
     if (doRestart)
     {
         StartThread();
     }
 }
Exemple #7
0
        void timer_Tick()
        {
            int        i = Thread.CurrentThread.ManagedThreadId;
            TCP_Client test;
            Random     rand = new Random();

            while (true)
            {
                Thread.Sleep(rand.Next(3000, 5000));
                test = new TCP_Client();

                test.Send("IP=[" + i + "]Chat=Test" + i + ": Testing");

                // test.Send("IP=[" + i + "]Jukebox=0: Sleep Away");
            }
        }
    public void createMapList()
    {
        bool connectSuccess = false;

        mapNameList.Clear();
        mapListDropDown.ClearOptions();

        tcpClient      = new TCP_Client(serverIP, serverPort);
        connectSuccess = tcpClient.ClientConnect();

        if (!connectSuccess)
        {
            return;
        }

        tcpClient.WriteString("List");

        string mapListString = tcpClient.ReadString();

        Debug.Log(mapListString);

        tcpClient.CloseClient();

        // 產生 Map List
        mapNameList.Clear();
        foreach (string mapName in mapListString.Split(' '))
        {
            mapNameList.Add(mapName);
        }

        if (!(selectMapName != mapNameList[0] && mapNameList.Contains(selectMapName)))
        {
            selectMapName = mapNameList[0];
        }

        // 建立 mapListDropDown
        mapListDropDown.AddOptions(mapNameList);
    }
    public void downloadMap()
    {
        int fileSize;

        bool connectSuccess = false;

        tcpClient      = new TCP_Client(serverIP, serverPort);
        connectSuccess = tcpClient.ClientConnect();

        if (!connectSuccess)
        {
            return;
        }

        tcpClient.WriteString("Download " + selectMapName);
        fileSize = tcpClient.ReceiveFile(Application.persistentDataPath + "/" + selectMapName + ".zip");

        tcpClient.CloseClient();

        //debugFileSizeText.text = fileSize.ToString();

        Unzip();
        StartCoroutine(ShowAndHide(GameObject.Find("MenuMap"), 3.0f));   // 1 second
    }
Exemple #10
0
 public BKSClient(TCP_Client _TCP_Client, Socket _MySocket)
 {
     myTCP_Module = _TCP_Client;
     mySocket     = _MySocket;
 }
Exemple #11
0
        private void btnDropOther_Click(object sender, EventArgs e)
        {
            TCP_Client selClient = (TCP_Client)dgvOther.Rows[dgvOther.SelectedRows[0].Index].DataBoundItem;

            _tcpServer.RemoveOtherClient(selClient);
        }
Exemple #12
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Server()
 {
     m_pClient           = new TCP_Client();
     m_pLockSynchronizer = m_pClient;
 }
Exemple #13
0
        /// <summary>
        /// Starts flow processing.
        /// </summary>
        internal void Start()
        {
            // Move processing to thread pool.
            AutoResetEvent startLock = new AutoResetEvent(false);
            ThreadPool.QueueUserWorkItem(delegate
                                             {
                                                 lock (m_pLock)
                                                 {
                                                     startLock.Set();

                                                     // TCP / TLS client, connect to remote end point.
                                                     if (!m_IsServer && m_Transport != SIP_Transport.UDP)
                                                     {
                                                         try
                                                         {
                                                             TCP_Client client = new TCP_Client();
                                                             client.Connect(m_pLocalEP,
                                                                            m_pRemoteEP,
                                                                            m_Transport == SIP_Transport.TLS);

                                                             m_pTcpSession = client;

                                                             BeginReadHeader();
                                                         }
                                                         catch
                                                         {
                                                             Dispose();
                                                         }
                                                     }
                                                 }
                                             });
            startLock.WaitOne();
        }