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"); } } }
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); }
public GameMgr() { m_ct = new ClientNet(); m_player = PlayerManager.get_instance(); m_syncmgr = new SyncManager(); m_syncmgr.init(); m_ipmgr = new InputManager(); }
/// <summary> /// 应用程序退出回调 /// </summary> public void OnDestroy() { if (mClientNet != null) { mClientNet.UnInit(); mClientNet = null; } }
public MainPage() { InitializeComponent(); count = 0; //client = new ClientCore(); client = new ClientNet(); }
/// <summary> /// 手动调用释放,onDestroy不及时 /// </summary> public void FreeOnDestroy() { if (mClientNet != null) { mClientNet.ShutDown(); mClientNet.UnInit(); mClientNet = null; } }
public static void StartNetwork(NetworkProtol np) { if (np == NetworkProtol.Tcp) { m_TcpNet = new ClientNet(); } else if (np == NetworkProtol.Kcp) { //m_KcpNet = new KCPNet(); } }
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); }
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; }
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); }
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; } }
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); }
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"]); } }
public static void CompleteStartCountdown(int nTimeMs, ClientNet cliNet) { cliNet._clientEvent.OnCompleteStartCountdown(nTimeMs); }
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; }
public static void UserPropose(ClientNet cliNet) { cliNet.Core.DoUserPropose(); }
public static void MatchingGameInfo(MatchData mData, ClientNet cliNet) { cliNet.Core.OnMatchingGameInfo(mData); }
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; } }
public static void GameInfo(int nResCode, int nFinalCount, ClientNet cliNet) { cliNet._clientEvent.OnMatchingGameResult(nResCode,nFinalCount); }
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); }
private void HandleNetConnecting(ClientNet net) { //CallAction<int>(NetNotification.CLIENT_NET_CONNECDTING, net.UniqueID); }
private void HandleNetConnectedSuccess(ClientNet net) { //CallAction<int>(NetNotification.CLIENT_NET_CONNECTED_SUCCESS, net.UniqueID); }
// Start is called before the first frame update void Start() { mNet = new ClientNet(); mNet.SetCallBack(mCallBack); }
public GHeartBeat(int interval , ClientNet net) { this.interval = interval; IsConnected = true; this.net = net; }
public GHeartBeat(int interval, ClientNet net) { this.interval = interval; IsConnected = true; this.net = net; }
public void Release() { if (_ClientNet != null) { _ClientNet.Close(); _ClientNet = null; } _roleDataMap.Clear(); _gameData = null; _matchData.Clear(); _matchResultInfoList.Clear(); AccountID = 0; CurRoleID = 0; }
public static void CreateRoleResult(int nResCode, long lnRoleID, ClientNet cliNet) { cliNet._clientEvent.OnCreateRoleResult(nResCode, lnRoleID); }
public static void RoleInfo(RoleData role, ClientNet cliNet) { cliNet.Core.AddRoleInfo(role); cliNet._clientEvent.OnRoleDataRefresh(role); }
public static void GameInfo(GameData gData, ClientNet cliNet) { cliNet.Core.OnGameInfo(gData); }
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); }
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); }
public static void MatchingDelRol(long lnRoleID, ClientNet cliNet) { cliNet.Core.OnMatchingDelRol(lnRoleID); }
public static void SyncUseItem(int nItemIndex, ClientNet cliNet) { cliNet._clientEvent.OnSyncUseItem(nItemIndex); }
private void HandleNetDisconnected(ClientNet net) { //CallAction<int>(NetNotification.CLIENT_NET_DISCONNECTED, net.UniqueID); }
public static void UserItemResult(int nResCode, ClientNet cliNet) { cliNet._clientEvent.OnUserItemResult(nResCode); }
public static void StartGame(ClientNet cliNet) { cliNet._clientEvent.OnStartGame(); }
private void HandleNetConnectedFailed(ClientNet net) { //CallAction<int>(NetNotification.CLIENT_NET_CONNECTED_FAILED, net.UniqueID); }