Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("gRPC client tester");
            int count = 0;
            //var client = new ClientCore();
            var client = new ClientNet();

            while (true)
            {
                var key = Console.ReadLine();
                if (key == "q")
                {
                    break;
                }
                if (key == "a")
                {
                    count++;
                    client.SendSayHelloRequest("localhost", 50001, "Console", count);
                }
                else if (key == "b")
                {
                    count++;
                    client.SendGetHelloRequest("localhost", 50001, "Console", count);
                }
                else if (key == "c")
                {
                    count++;
                    client.SendGetStreamHelloRequest("localhost", 50001, "Console", count);
                }
                else
                {
                    Console.WriteLine("Wrong key");
                }
            }
        }
Esempio n. 2
0
    void SetSocket()
    {
        // 소켓 설치
        gameObject.AddComponent <ClientNet>();
        mNet = GetComponent <ClientNet>();

        // @request UID 발급 신청
        StructRequest request = new StructRequest();

        request.uid         = "";
        request.request_url = URL.InitUser.ToString();

        void CallBack(StructRequest response)
        {
            if (response.uid != null)
            {
                mUserData           = new StructUserData();
                mUserData.uid       = response.uid;
                mUserData.isPVPMode = true;
                string map_data  = response.parameter["mapData"];
                string item_data = response.parameter["itemData"];

                // 맵 데이터에 저장
                JsonFactory.WriteString(Const.MapDataName, map_data);
                mUserData.itemData = item_data;
            }
        }

        mNet.SetCallBack(CallBack);
        mNet.RequestMsg(request);
    }
Esempio n. 3
0
 public GameMgr()
 {
     m_ct      = new ClientNet();
     m_player  = PlayerManager.get_instance();
     m_syncmgr = new SyncManager();
     m_syncmgr.init();
     m_ipmgr = new InputManager();
 }
Esempio n. 4
0
 /// <summary>
 /// 应用程序退出回调
 /// </summary>
 public void OnDestroy()
 {
     if (mClientNet != null)
     {
         mClientNet.UnInit();
         mClientNet = null;
     }
 }
Esempio n. 5
0
        public MainPage()
        {
            InitializeComponent();

            count = 0;
            //client = new ClientCore();
            client = new ClientNet();
        }
Esempio n. 6
0
 /// <summary>
 /// 手动调用释放,onDestroy不及时
 /// </summary>
 public void FreeOnDestroy()
 {
     if (mClientNet != null)
     {
         mClientNet.ShutDown();
         mClientNet.UnInit();
         mClientNet = null;
     }
 }
Esempio n. 7
0
 public static void StartNetwork(NetworkProtol np)
 {
     if (np == NetworkProtol.Tcp)
     {
         m_TcpNet = new ClientNet();
     }
     else if (np == NetworkProtol.Kcp)
     {
         //m_KcpNet = new KCPNet();
     }
 }
Esempio n. 8
0
        public ClientNet CreateNet(int netID, IMessageParser messageParser)
        {
            ClientNet clientNet = NetManager.GetInstance().CreateClientNet(netID, messageParser);

            clientNet.NetConnecting       += HandleNetConnecting;
            clientNet.NetConnectedSuccess += HandleNetConnectedSuccess;
            clientNet.NetConnectedFailed  += HandleNetConnectedFailed;
            clientNet.NetDisconnected     += HandleNetDisconnected;

            clientNetDic.Add(netID, clientNet);
            return(clientNet);
        }
Esempio n. 9
0
 public static void LoginRes(int nResCode, ClientNet cliNet)
 {
     // SvrTrace.Log("LoginRes:: " + nResCode.ToString());
     if (nResCode < 0)
     {
         cliNet._clientEvent.OnLoginResult(0, -1);
     }
     else
     {
         cliNet._clientEvent.OnLoginResult(nResCode,0);
     }
 }
    private void Start()
    {
        // 소켓 설치
        gameObject.AddComponent <ClientNet>();
        mNEt = this.GetComponent <ClientNet>();

        // 로컬 데이터에 들어있는 유저 정보 저장
        string         data  = JsonFactory.Load(Const.UserDataName);
        StructUserData _data = JsonUtility.FromJson <StructUserData>(data);

        Const.UserData = _data;
    }
Esempio n. 11
0
    public void ConnectWebSocket()
    {
        if (pc != null)
        {
            if (pc.disposed == false)
            {
                return;
            }
        }

        pc = new ClientNet(ConfigFactory.WebSocketHost);
        pc.connect();
    }
        /*
         * 向服务端发送数据
         * **/
        public void sendToServer(global::ProtoBuf.IExtensible netMsg)
        {
            Type msgType = netMsg.GetType();
            uint msgId   = NetMsgMap.instance.getMsgIdByType(msgType);

            byte[] byteArr
                = Parse <global::ProtoBuf.IExtensible>(netMsg, msgId);

            if (null == _clientNet)
            {
                _clientNet = ClientNet.Singleton;
            }

            _clientNet.SendPacket(byteArr);
        }
Esempio n. 13
0
 public static void MatchResultInfo(MatchResultInfo resInfo, ClientNet cliNet)
 {
     cliNet.Core.OnMatchResultInfo(resInfo);
     if (resInfo.lnRoleID == cliNet.Core.CurRoleID)
     {
         RoleData data = cliNet.Core.GetRoleInfoByID(cliNet.Core.CurRoleID);
         data.nGold = resInfo.nGold;
         data.lnExp = resInfo.lnExp;
         data.nLevel = resInfo.nLevel;
         cliNet._clientEvent.OnRoleDataRefresh(data);
     }
     if (cliNet.Core.EMT_SC_MatchShowResultUI_nCount > 0 && cliNet.Core.EMT_SC_MatchShowResultUI_nCount == cliNet.Core.ResultListCount)
     {
         cliNet._clientEvent.OnMatchShowResultUI(cliNet.Core.EMT_SC_MatchShowResultUI_nCount, cliNet.Core.EMT_SC_MatchShowResultUI_bAllFinish);
         cliNet.Core.EMT_SC_MatchShowResultUI_nCount = -1;
     }
 }
Esempio n. 14
0
        public ClientNet CreateClientNet(int netID, IMessageParser messageParser)
        {
            if (clientNetDic == null)
            {
                clientNetDic = new Dictionary <int, ClientNet>();
            }
            if (clientNetDic.ContainsKey(netID))
            {
                DebugLog.Error(NetConst.CLIENT_LOGGER_TAG, $"NetMananger::CreateClientNet->the net has been created.netID={netID}");
                return(null);
            }

            ClientNet net = new ClientNet(netID, messageParser);

            clientNetDic.Add(netID, net);

            return(net);
        }
Esempio n. 15
0
    public Message(string message)
    {
        string     realMesage = ClientNet.getReceivedMessage(message);
        JsonObject obj        = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(realMesage);

        if (obj.ContainsKey("reqId"))
        {
            type = WBMessageType.MSG_REQUEST;
            id   = Convert.ToUInt32(obj["reqId"]);
        }
        else
        {
            type = WBMessageType.MSG_RESPONSE;
        }
        if (obj.ContainsKey("handler"))
        {
            handler = Convert.ToString(obj["handler"]);
        }
        if (obj.ContainsKey("msg"))
        {
            msg = Convert.ToString(obj["msg"]);
        }
    }
Esempio n. 16
0
 public static void CompleteStartCountdown(int nTimeMs, ClientNet cliNet)
 {
     cliNet._clientEvent.OnCompleteStartCountdown(nTimeMs);
 }
Esempio n. 17
0
 public bool LoginToSvr(string szIP, int nPort, long lnAccID, long nTime, string szMD5)
 {
     _ClientNet = new ClientNet(this);
     _ClientNet._clientEvent = _pEvent;
     if (!_ClientNet.Login(szIP, nPort, lnAccID, nTime, szMD5))
     {
         return false;
     }
     AccountID = lnAccID;
     return true;
 }
Esempio n. 18
0
 public static void UserPropose(ClientNet cliNet)
 {
     cliNet.Core.DoUserPropose();
 }
Esempio n. 19
0
 public static void MatchingGameInfo(MatchData mData, ClientNet cliNet)
 {
     cliNet.Core.OnMatchingGameInfo(mData);
 }
Esempio n. 20
0
 public static void MatchShowResultUI(int nCount, bool bAllFinish, ClientNet cliNet)
 {
     if (cliNet.Core.ResultListCount == nCount)
     {
         cliNet._clientEvent.OnMatchShowResultUI(nCount, bAllFinish);
         cliNet.Core.EMT_SC_MatchShowResultUI_nCount = -1;
     }
     else
     {
         cliNet.Core.EMT_SC_MatchShowResultUI_nCount = nCount;
         cliNet.Core.EMT_SC_MatchShowResultUI_bAllFinish = bAllFinish;
     }
 }
Esempio n. 21
0
 public static void GameInfo(int nResCode, int nFinalCount, ClientNet cliNet)
 {
     cliNet._clientEvent.OnMatchingGameResult(nResCode,nFinalCount);
 }
Esempio n. 22
0
    public void ConnectWebSocket()
    {
        if (pc != null)
            if (pc.disposed == false)
                return;

        pc = new ClientNet(ConfigFactory.WebSocketHost);
        pc.connect();
    }
 public static void UnRegistMessage(ClientNet msgID, MobaMessageFunc msgFunc)
 {
     MobaMessageManager.UnRegistMessage((ClientMsg)msgID, msgFunc);
 }
Esempio n. 24
0
 private void HandleNetConnecting(ClientNet net)
 {
     //CallAction<int>(NetNotification.CLIENT_NET_CONNECDTING, net.UniqueID);
 }
Esempio n. 25
0
 private void HandleNetConnectedSuccess(ClientNet net)
 {
     //CallAction<int>(NetNotification.CLIENT_NET_CONNECTED_SUCCESS, net.UniqueID);
 }
Esempio n. 26
0
 // Start is called before the first frame update
 void Start()
 {
     mNet = new ClientNet();
     mNet.SetCallBack(mCallBack);
 }
Esempio n. 27
0
 public GHeartBeat(int interval , ClientNet net)
 {
     this.interval = interval;
     IsConnected = true;
     this.net = net;
 }
Esempio n. 28
0
 public GHeartBeat(int interval, ClientNet net)
 {
     this.interval = interval;
     IsConnected   = true;
     this.net      = net;
 }
Esempio n. 29
0
 public void Release()
 {
     if (_ClientNet != null)
     {
         _ClientNet.Close();
         _ClientNet = null;
     }
     _roleDataMap.Clear();
     _gameData = null;
     _matchData.Clear();
     _matchResultInfoList.Clear();
     AccountID = 0;
     CurRoleID = 0;
 }
Esempio n. 30
0
 public static void CreateRoleResult(int nResCode, long lnRoleID, ClientNet cliNet)
 {
     cliNet._clientEvent.OnCreateRoleResult(nResCode, lnRoleID);
 }
Esempio n. 31
0
 public static void RoleInfo(RoleData role, ClientNet cliNet)
 {
     cliNet.Core.AddRoleInfo(role);
     cliNet._clientEvent.OnRoleDataRefresh(role);
 }
Esempio n. 32
0
 public static void GameInfo(GameData gData, ClientNet cliNet)
 {
     cliNet.Core.OnGameInfo(gData);
 }
Esempio n. 33
0
 public static void SelectRoleResult(int nResCode, long lnRoleID, ClientNet cliNet)
 {
     cliNet.Core.CurRoleID = 0;
     if (nResCode == 0)
     {
         cliNet.Core.CurRoleID = lnRoleID;
     }
     cliNet._clientEvent.OnSelectRoleResult(nResCode,lnRoleID);
 }
Esempio n. 34
0
 public static void GameInfo(PlayerSyncInfo syncInfo, ClientNet cliNet)
 {
     cliNet._clientEvent.OnUserSyncPosInfo(syncInfo);
 }
        /*发起连接请求
         * **/
        public void ConnectIP(string ip, int port)
        {
            ClientNet cn = ClientNet.Singleton;

            cn.ConnectIP(GameConfig.SERVER_HOST, GameConfig.SERVER_PORT);
        }
Esempio n. 36
0
 public static void MatchingDelRol(long lnRoleID, ClientNet cliNet)
 {
     cliNet.Core.OnMatchingDelRol(lnRoleID);
 }
Esempio n. 37
0
 public static void SyncUseItem(int nItemIndex, ClientNet cliNet)
 {
     cliNet._clientEvent.OnSyncUseItem(nItemIndex);
 }
Esempio n. 38
0
 private void HandleNetDisconnected(ClientNet net)
 {
     //CallAction<int>(NetNotification.CLIENT_NET_DISCONNECTED, net.UniqueID);
 }
Esempio n. 39
0
 public static void UserItemResult(int nResCode, ClientNet cliNet)
 {
     cliNet._clientEvent.OnUserItemResult(nResCode);
 }
Esempio n. 40
0
 public static void StartGame(ClientNet cliNet)
 {
     cliNet._clientEvent.OnStartGame();
 }
Esempio n. 41
0
 private void HandleNetConnectedFailed(ClientNet net)
 {
     //CallAction<int>(NetNotification.CLIENT_NET_CONNECTED_FAILED, net.UniqueID);
 }