示例#1
0
        public static void switchServer(HostType type, string host, string port)
        {
            switch (type)
            {
            case HostType.Local:
                LocalDataModel.currentHost = host;
                break;

            case HostType.Product:
                LocalDataModel.currentHost = "127.0.0.1";
                break;

            case HostType.Development:
                LocalDataModel.currentHost = "127.0.0.1";
                break;
            }
            if (port != null && port.Length > 0)
            {
                LocalDataModel.currentLoginPort = System.Convert.ToInt32(port);
            }
            else
            {
                LocalDataModel.currentLoginPort = 0;
            }
            s_gateServer = null;
        }
示例#2
0
 public static ServiceGate getInstance()
 {
     if (s_gateServer == null)
     {
         if (LocalDataModel.currentHost != null)
         {
             Host = LocalDataModel.currentHost;
         }
         s_gateServer = new ServiceGate(Host, Port);
     }
     return(s_gateServer);
 }
示例#3
0
        public static void queryEntry(Action <EntryResponse> callBack)
        {
            string     route = "gate.gateHandler.queryEntry";
            JsonObject param = new JsonObject();

            ServiceGate.getInstance().request(route, param, ((JsonObject obj) => {
//				Debug.Log("obj = " + obj);
                EntryResponse model = new EntryResponse(obj);
                if (callBack != null)
                {
                    callBack(model);
                }
                ServiceGate.disconnect();
            }));
        }
示例#4
0
 public static void connect(Action <JsonObject> callback)
 {
     ProgressHUDManager.showHUD("正在分配服务器");
     ServiceGate.getInstance().connectToServer((JsonObject obj) => {
         ProgressHUDManager.hideCurrentHUD();
         BaseModel model = new BaseModel(obj);
         if (model.timeout)
         {
             reconnectGate(callback);
         }
         else
         {
             if (callback != null)
             {
                 callback(obj);
             }
         }
     });
 }
示例#5
0
 public static void disconnect()
 {
     ServiceGate.getInstance().pclient.disconnect();
 }