예제 #1
0
        public void Connect(SocketId sid, string url, int port)
        {
            Debug.Log(Time.time + " SocketMananger.Connect sid=" + sid + "  url=" + url + "  port=" + port);
            int i = (int)sid;

//			if (servers [i] != null)
//			{
//				if(Application.isEditor) Debug.LogError ("socket已经连接,之前没有关闭 sid=" + sid );
//				Close (sid);
//			}

            if (servers[i] == null)
            {
                if (string.IsNullOrEmpty(url) || url.ToUpper() == OFFLINE)
                {
                    Offline(sid);
                }
                else
                {
                    var s = new CommonSocketServer(this, sid);
//                    s.root = root;
                    s.URL        = url;
                    s.Port       = port;
                    s.ReconnSpan = 5;
                    if (connectedCallback != null)
                    {
                        s.sConnect.AddListener(connectedCallback);
                    }

                    servers[i] = s;
                    s.Start();
                }
            }
        }
예제 #2
0
 public void StopAll()
 {
     foreach (ISocketServer server in servers)
     {
         if (server != null && server is CommonSocketServer)
         {
             CommonSocketServer s = server as CommonSocketServer;
             s.Stop();
         }
     }
 }
예제 #3
0
        public void Stop(SocketId sid)
        {
            int i = (int)sid;

            if (servers[i] != null)
            {
                if (servers[i] is CommonSocketServer)
                {
                    CommonSocketServer s = servers[i] as CommonSocketServer;
                    s.Stop();
                }
            }
        }