Ejemplo n.º 1
0
 void OnDisable()
 {
     if (_current == this)
     {
         _current = null;
     }
 }
Ejemplo n.º 2
0
        public void StopServer()
        {
            Cancelled = true;
            Thread.Sleep(80);

            CloseConnection();

            try
            {
                TcpServer?.Stop();
                TcpServer = null;
            }
            catch
            {
                TcpServer = null;
            }

            try
            {
                SocketThread?.Abort();
            }
            finally
            {
                SocketThread = null;
            }
        }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     ct = new SocketThread(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, "163.13.201.90", 36001);
     ct.StartConnect();
     isSend     = true;
     LoginError = GameObject.Find("LoginError").GetComponent <Text>();
     //LoginError.gameObject.SetActive(false);
     LoginError.enabled = false;
 }
Ejemplo n.º 4
0
    // Use this for initialization

    void Start()
    {
        ErrorMessagePassWord         = GameObject.Find("ErrorMessagePassWord").GetComponent <Text>();
        ErrorMessagePassWord.enabled = false;
        ErrorMessageGender           = GameObject.Find("ErrorMessageGender").GetComponent <Text>();
        ErrorMessageGender.enabled   = false;

        ct = new SocketThread(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp, "163.13.201.90", 36000);
        ct.StartConnect();
        isSend = true;
    }
Ejemplo n.º 5
0
 static void Initialize()
 {
     if (!initialized)
     {
         if (!Application.isPlaying)
         {
             return;
         }
         initialized = true;
         var g = new GameObject("SocketThread");
         _current = g.AddComponent <SocketThread>();
     }
 }
Ejemplo n.º 6
0
 public static void Release()
 {
     if (!isMainThread())
     {
         return;
     }
     if (null == _instance)
     {
         return;
     }
     GameObject.Destroy(_instance.gameObject);
     _instance = null;
 }
Ejemplo n.º 7
0
 public void StartSocket()
 {
     clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
     try
     {
         clientSocket.Connect(m_ServerIP, int.Parse(m_ServerPort));
         Debug.Log("Server connect success");
         //Thread thread = new Thread(GetSocketData);
         //thread.Start();
         //Loom.RunAsync(GetSocketData);
         SocketThread.RunAsync(GetSocketData);
     }
     catch
     {
         Debug.Log("ServerConnect Failed");
         return;
     }
 }
Ejemplo n.º 8
0
    public static void initilize(Action updateHandle = null)
    {
        if (_instance != null)
        {
            return;
        }
        mainThread = System.Threading.Thread.CurrentThread.ManagedThreadId;
        GameObject obj = GameObject.Find(Tag);

        if (obj == null)
        {
            obj      = new GameObject();
            obj.name = Tag;
        }
        _instance = obj.GetComponent <SocketThread>();
        if (_instance == null)
        {
            _instance = obj.AddComponent <SocketThread>();
        }
        _instance.setHandle(updateHandle);
        GameObject.DontDestroyOnLoad(obj);
    }
Ejemplo n.º 9
0
 void Awake()
 {
     _current    = this;
     initialized = true;
 }