网络模块的用途,网络模块有哪些

强联网:

    必须输入用户名和密码等服务器确认,才可以进入游戏。

面板操作登陆

LoginCtrl.Instance.LoginmLoginAccountInput.value, mLoginPassInput.value);//验证登录名和登录密码

Control控制

public void Loginstring account, string pass) { //设置用户名和密码 SelectServerData.Instance.SetServerInfoint)SdkManager.Instance.GetPlatFrom), account, pass); //网络先切断,再连接 NetworkManager.Instance.canReconnect = false; NetworkManager.Instance.Close); NetworkManager.Instance.InitGameLogic.Instance.LoginServerAdress,GameLogic.Instance.LoginServerPort, NetworkManager.ServerType.LoginServer); }

下面的方法会在Update中执行

登陆错误,广播一条消息

 

登陆成功

开始游戏   

登陆信息保存起来

网络处理

找到连接的分类

 

对连接的protobuf进行填充,然后序列化

public void SendMsgProtoBuf.IExtensible pMsg, Int32 n32MsgID) { if m_Client != null) { //清除stream mSendStream.SetLength0); mSendStream.Position = 0; //序列到stream ProtoBuf.Serializer.SerializemSendStream, pMsg); CMsg pcMsg = new CMsgint)mSendStream.Length); pcMsg.SetProtocalIDn32MsgID); pcMsg.AddmSendStream.ToArray), 0, int)mSendStream.Length);//放入到队列中 //ms.Close);#if UNITY_EDITOR#else try {#endif#if LOG_FILE && UNITY_EDITOR if n32MsgID != 8192 && n32MsgID != 16385) { string msgName = “”; if Enum.IsDefinedtypeofGCToBS.MsgNum), n32MsgID)) { msgName = GCToBS.MsgNum)n32MsgID).ToString); } else if Enum.IsDefinedtypeofGCToCS.MsgNum), n32MsgID)) { msgName = GCToCS.MsgNum)n32MsgID).ToString); } else if Enum.IsDefinedtypeofGCToLS.MsgID), n32MsgID)) { msgName = GCToLS.MsgID)n32MsgID).ToString); } else if Enum.IsDefinedtypeofGCToSS.MsgNum), n32MsgID)) { msgName = GCToSS.MsgNum)n32MsgID).ToString); } using System.IO.StreamWriter sw = new System.IO.StreamWriter@”E:\Log.txt”, true)) { sw.WriteLineTime.time + ” 发送消息:\t” + n32MsgID + “\t” + msgName); } }#endif m_Client.GetStream).WritepcMsg.GetMsgBuffer), 0, int)pcMsg.GetMsgSize));//写入流里面以便发出去#if UNITY_EDITOR#else } catch Exception exc) { Debugger.LogErrorexc.ToString)); Close); }#endif } }ProtoBuf.Serializer.SerializemSendStream, pMsg); CMsg pcMsg = new CMsgint)mSendStream.Length); pcMsg.SetProtocalIDn32MsgID); pcMsg.AddmSendStream.ToArray), 0, int)mSendStream.Length);//放入到队列中 //ms.Close);#if UNITY_EDITOR#else try {#endif#if LOG_FILE && UNITY_EDITOR if n32MsgID != 8192 && n32MsgID != 16385) { string msgName = “”; if Enum.IsDefinedtypeofGCToBS.MsgNum), n32MsgID)) { msgName = GCToBS.MsgNum)n32MsgID).ToString); } else if Enum.IsDefinedtypeofGCToCS.MsgNum), n32MsgID)) { msgName = GCToCS.MsgNum)n32MsgID).ToString); } else if Enum.IsDefinedtypeofGCToLS.MsgID), n32MsgID)) { msgName = GCToLS.MsgID)n32MsgID).ToString); } else if Enum.IsDefinedtypeofGCToSS.MsgNum), n32MsgID)) { msgName = GCToSS.MsgNum)n32MsgID).ToString); } using System.IO.StreamWriter sw = new System.IO.StreamWriter@”E:\Log.txt”, true)) { sw.WriteLineTime.time + ” 发送消息:\t” + n32MsgID + “\t” + msgName); } }#endif m_Client.GetStream).WritepcMsg.GetMsgBuffer), 0, int)pcMsg.GetMsgSize));//写入流里面以便发出去#if UNITY_EDITOR#else } catch Exception exc) { Debugger.LogErrorexc.ToString)); Close); }#endif } }

 

Published by

风君子

独自遨游何稽首 揭天掀地慰生平

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注