diff --git a/.vs/HaoYueTunnel/DesignTimeBuild/.dtbcache.v2 b/.vs/HaoYueTunnel/DesignTimeBuild/.dtbcache.v2 index 7f33bff..4bf1430 100644 Binary files a/.vs/HaoYueTunnel/DesignTimeBuild/.dtbcache.v2 and b/.vs/HaoYueTunnel/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/HaoYueTunnel/FileContentIndex/0d6e9f1c-0ad9-4cba-8288-adecc01a5487.vsidx b/.vs/HaoYueTunnel/FileContentIndex/0d6e9f1c-0ad9-4cba-8288-adecc01a5487.vsidx new file mode 100644 index 0000000..7f87d20 Binary files /dev/null and b/.vs/HaoYueTunnel/FileContentIndex/0d6e9f1c-0ad9-4cba-8288-adecc01a5487.vsidx differ diff --git a/.vs/HaoYueTunnel/FileContentIndex/19cba2f7-6349-4434-947c-5e3eb587ed49.vsidx b/.vs/HaoYueTunnel/FileContentIndex/19cba2f7-6349-4434-947c-5e3eb587ed49.vsidx new file mode 100644 index 0000000..f05dad9 Binary files /dev/null and b/.vs/HaoYueTunnel/FileContentIndex/19cba2f7-6349-4434-947c-5e3eb587ed49.vsidx differ diff --git a/.vs/HaoYueTunnel/FileContentIndex/1cc7a82a-ea20-4973-bcb7-542bd88566c7.vsidx b/.vs/HaoYueTunnel/FileContentIndex/1cc7a82a-ea20-4973-bcb7-542bd88566c7.vsidx deleted file mode 100644 index 2c081b0..0000000 Binary files a/.vs/HaoYueTunnel/FileContentIndex/1cc7a82a-ea20-4973-bcb7-542bd88566c7.vsidx and /dev/null differ diff --git a/.vs/HaoYueTunnel/FileContentIndex/27599ba5-70bd-4b54-8cce-a9bca9e2f1cb.vsidx b/.vs/HaoYueTunnel/FileContentIndex/27599ba5-70bd-4b54-8cce-a9bca9e2f1cb.vsidx new file mode 100644 index 0000000..9b0ee57 Binary files /dev/null and b/.vs/HaoYueTunnel/FileContentIndex/27599ba5-70bd-4b54-8cce-a9bca9e2f1cb.vsidx differ diff --git a/.vs/HaoYueTunnel/FileContentIndex/6fa45efc-1933-4db1-8add-8bb0c9b151c9.vsidx b/.vs/HaoYueTunnel/FileContentIndex/6fa45efc-1933-4db1-8add-8bb0c9b151c9.vsidx deleted file mode 100644 index 2249493..0000000 Binary files a/.vs/HaoYueTunnel/FileContentIndex/6fa45efc-1933-4db1-8add-8bb0c9b151c9.vsidx and /dev/null differ diff --git a/.vs/HaoYueTunnel/FileContentIndex/9a839e95-4e9d-43b2-b563-46a2d2493710.vsidx b/.vs/HaoYueTunnel/FileContentIndex/9a839e95-4e9d-43b2-b563-46a2d2493710.vsidx new file mode 100644 index 0000000..9625560 Binary files /dev/null and b/.vs/HaoYueTunnel/FileContentIndex/9a839e95-4e9d-43b2-b563-46a2d2493710.vsidx differ diff --git a/.vs/HaoYueTunnel/FileContentIndex/eb693277-1230-48ff-85e0-dc3966eeaa35.vsidx b/.vs/HaoYueTunnel/FileContentIndex/eb693277-1230-48ff-85e0-dc3966eeaa35.vsidx deleted file mode 100644 index 2918002..0000000 Binary files a/.vs/HaoYueTunnel/FileContentIndex/eb693277-1230-48ff-85e0-dc3966eeaa35.vsidx and /dev/null differ diff --git a/.vs/HaoYueTunnel/FileContentIndex/eddf0a80-e211-4d6a-a120-82145c39f49f.vsidx b/.vs/HaoYueTunnel/FileContentIndex/eddf0a80-e211-4d6a-a120-82145c39f49f.vsidx deleted file mode 100644 index 34e577c..0000000 Binary files a/.vs/HaoYueTunnel/FileContentIndex/eddf0a80-e211-4d6a-a120-82145c39f49f.vsidx and /dev/null differ diff --git a/.vs/HaoYueTunnel/v17/.futdcache.v2 b/.vs/HaoYueTunnel/v17/.futdcache.v2 index a277455..da5b4e8 100644 Binary files a/.vs/HaoYueTunnel/v17/.futdcache.v2 and b/.vs/HaoYueTunnel/v17/.futdcache.v2 differ diff --git a/.vs/HaoYueTunnel/v17/.suo b/.vs/HaoYueTunnel/v17/.suo index 5d95671..4e6d512 100644 Binary files a/.vs/HaoYueTunnel/v17/.suo and b/.vs/HaoYueTunnel/v17/.suo differ diff --git a/.vs/ProjectEvaluation/haoyuetunnel.metadata.v5.2 b/.vs/ProjectEvaluation/haoyuetunnel.metadata.v5.2 index 7e0047c..8a218e4 100644 Binary files a/.vs/ProjectEvaluation/haoyuetunnel.metadata.v5.2 and b/.vs/ProjectEvaluation/haoyuetunnel.metadata.v5.2 differ diff --git a/.vs/ProjectEvaluation/haoyuetunnel.projects.v5.2 b/.vs/ProjectEvaluation/haoyuetunnel.projects.v5.2 index 79af811..f737e8e 100644 Binary files a/.vs/ProjectEvaluation/haoyuetunnel.projects.v5.2 and b/.vs/ProjectEvaluation/haoyuetunnel.projects.v5.2 differ diff --git a/Client-Cli/Program.cs b/Client-Cli/Program.cs index 9f826d6..30e119f 100644 --- a/Client-Cli/Program.cs +++ b/Client-Cli/Program.cs @@ -1,18 +1,41 @@ using ClientCore; -ClientManager.Init("127.0.0.1", 23846); +App.Init("127.0.0.1", 23846); + +//注册 +App.chat.OnChatMsg += OnChatMsg; while (true) { string CommandStr = Console.ReadLine(); string Command = ""; Command = ((CommandStr.IndexOf(" ") <= 0) ? CommandStr : CommandStr.Substring(0, CommandStr.IndexOf(" "))); + string[] CmdArr = CommandStr.Split(' '); switch (Command) { case "login": - StaticComm.login.Login(); + case "l": + if (CmdArr.Length < 2) + { + Console.WriteLine("缺省用户名"); + return; + } + App.login.Login(CmdArr[1]); + break; + case "say": + if (CmdArr.Length < 2) + { + Console.WriteLine("缺省参数"); + return; + } + App.chat.SendChatMsg(CmdArr[1]); break; default: Console.WriteLine("未知命令" + CommandStr); break; } +} + +void OnChatMsg(string str1, string str2) +{ + Console.WriteLine($"[Chat]{str1}:{str2}"); } \ No newline at end of file diff --git a/ClientCore/StaticComm.cs b/ClientCore/AppLogic.cs similarity index 56% rename from ClientCore/StaticComm.cs rename to ClientCore/AppLogic.cs index acd10e7..aa5d724 100644 --- a/ClientCore/StaticComm.cs +++ b/ClientCore/AppLogic.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace ClientCore { - public class StaticComm + public class App { public static string TokenStr; public static long RID = -1; @@ -14,5 +14,16 @@ namespace ClientCore public static int Port; public static NetworkHelper networkHelper; public static AppLogin login; + public static AppChat chat; + + public static void Init(string IP, int port) + { + networkHelper = new NetworkHelper(); + login = new AppLogin(); + chat = new AppChat(); + networkHelper.Init(IP, port); + } } -} + + +} \ No newline at end of file diff --git a/ClientCore/Event/DelegateClass.cs b/ClientCore/Event/DelegateClass.cs new file mode 100644 index 0000000..3c972cb --- /dev/null +++ b/ClientCore/Event/DelegateClass.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static HaoYueNet.ClientNetwork.NetworkHelperCore; + +namespace ClientCore.Event +{ + public class DelegateClass + { + public delegate void dg_Str(string Msg); + public delegate void dg_Str_Str(string Str1, string Str2); + } +} diff --git a/ClientCore/Manager/AppChat.cs b/ClientCore/Manager/AppChat.cs new file mode 100644 index 0000000..9aab586 --- /dev/null +++ b/ClientCore/Manager/AppChat.cs @@ -0,0 +1,27 @@ +using AxibugProtobuf; +using System.Net.Sockets; +using static ClientCore.Event.DelegateClass; +using static HaoYueNet.ClientNetwork.NetworkHelperCore; + +namespace ClientCore +{ + public class AppChat + { + public event dg_Str_Str OnChatMsg; + + public void SendChatMsg(string ChatMsg) + { + Protobuf_ChatMsg msg = new Protobuf_ChatMsg() + { + ChatMsg = ChatMsg, + }; + App.networkHelper.SendToServer((int)CommandID.CmdChatmsg, NetBase.Serizlize(msg)); + } + + public void RecvChatMsg(byte[] reqData) + { + Protobuf_ChatMsg_RESP msg = NetBase.DeSerizlize(reqData); + OnChatMsg(msg.NickName, msg.ChatMsg); + } + } +} diff --git a/ClientCore/Manager/AppLogin.cs b/ClientCore/Manager/AppLogin.cs index 7e582bc..268e278 100644 --- a/ClientCore/Manager/AppLogin.cs +++ b/ClientCore/Manager/AppLogin.cs @@ -4,14 +4,14 @@ namespace ClientCore { public class AppLogin { - public void Login() + public void Login(string Account) { Protobuf_Login msg = new Protobuf_Login() { LoginType = 0, - //TODO + Account = Account, }; - StaticComm.networkHelper.SendToServer((int)CommandID.CmdLogin, NetBase.Serizlize(msg)); + App.networkHelper.SendToServer((int)CommandID.CmdLogin, NetBase.Serizlize(msg)); } } } diff --git a/ClientCore/Manager/ClientManager.cs b/ClientCore/Manager/ClientManager.cs deleted file mode 100644 index 39a7354..0000000 --- a/ClientCore/Manager/ClientManager.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace ClientCore -{ - public static class ClientManager - { - public static void Init(string IP,int port) - { - StaticComm.networkHelper = new NetworkHelper(); - StaticComm.login = new AppLogin(); - StaticComm.networkHelper.Init(IP, port); - } - } -} diff --git a/ClientCore/Network/NetworkHelper.cs b/ClientCore/Network/NetworkHelper.cs index 6aaf407..f3a7898 100644 --- a/ClientCore/Network/NetworkHelper.cs +++ b/ClientCore/Network/NetworkHelper.cs @@ -59,6 +59,7 @@ namespace ClientCore switch ((CommandID)CMDID) { case CommandID.CmdLogin: break; + case CommandID.CmdChatmsg: App.chat.RecvChatMsg(data); break; } } catch (Exception ex) diff --git a/Protobuf/ProtobufAuth.cs b/Protobuf/ProtobufAuth.cs index e369d6f..2ab2650 100644 --- a/Protobuf/ProtobufAuth.cs +++ b/Protobuf/ProtobufAuth.cs @@ -30,20 +30,25 @@ namespace AxibugProtobuf { "b2J1Zi5EZXZpY2VUeXBlEg8KB0FjY291bnQYAyABKAkSEAoIUGFzc3dvcmQY", "BCABKAkifwoTUHJvdG9idWZfTG9naW5fUkVTUBINCgVUb2tlbhgBIAEoCRIV", "Cg1MYXN0TG9naW5EYXRlGAIgASgJEg8KB1JlZ0RhdGUYAyABKAkSMQoGU3Rh", - "dHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0dXMq", - "KwoJQ29tbWFuZElEEg4KCkNNRF9ERUZBVUwQABIOCglDTURfTE9HSU4Q0Q8q", - "KwoJRXJyb3JDb2RlEhAKDEVSUk9SX0RFRkFVTBAAEgwKCEVSUk9SX09LEAEq", - "PgoJTG9naW5UeXBlEg8KC0Jhc2VEZWZhdWx0EAASDgoKSGFvWXVlQXV0aBAB", - "EgcKA0JGMxADEgcKA0JGNBAEKksKCkRldmljZVR5cGUSFgoSRGV2aWNlVHlw", - "ZV9EZWZhdWx0EAASBgoCUEMQARILCgdBbmRyb2lkEAISBwoDSU9TEAMSBwoD", - "UFNWEAQqTgoRTG9naW5SZXN1bHRTdGF0dXMSIQodTG9naW5SZXN1bHRTdGF0", - "dXNfQmFzZURlZmF1bHQQABIGCgJPSxABEg4KCkFjY291bnRFcnIQAkICSAFi", - "BnByb3RvMw==")); + "dHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0dXMi", + "IwoQUHJvdG9idWZfQ2hhdE1zZxIPCgdDaGF0TXNnGAEgASgJIkgKFVByb3Rv", + "YnVmX0NoYXRNc2dfUkVTUBIQCghOaWNrTmFtZRgBIAEoCRIPCgdDaGF0TXNn", + "GAIgASgJEgwKBERhdGUYAyABKAMqPQoJQ29tbWFuZElEEg4KCkNNRF9ERUZB", + "VUwQABIOCglDTURfTE9HSU4Q0Q8SEAoLQ01EX0NIQVRNU0cQoR8qKwoJRXJy", + "b3JDb2RlEhAKDEVSUk9SX0RFRkFVTBAAEgwKCEVSUk9SX09LEAEqPgoJTG9n", + "aW5UeXBlEg8KC0Jhc2VEZWZhdWx0EAASDgoKSGFvWXVlQXV0aBABEgcKA0JG", + "MxADEgcKA0JGNBAEKksKCkRldmljZVR5cGUSFgoSRGV2aWNlVHlwZV9EZWZh", + "dWx0EAASBgoCUEMQARILCgdBbmRyb2lkEAISBwoDSU9TEAMSBwoDUFNWEAQq", + "TgoRTG9naW5SZXN1bHRTdGF0dXMSIQodTG9naW5SZXN1bHRTdGF0dXNfQmFz", + "ZURlZmF1bHQQABIGCgJPSxABEg4KCkFjY291bnRFcnIQAkICSAFiBnByb3Rv", + "Mw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::AxibugProtobuf.CommandID), typeof(global::AxibugProtobuf.ErrorCode), typeof(global::AxibugProtobuf.LoginType), typeof(global::AxibugProtobuf.DeviceType), typeof(global::AxibugProtobuf.LoginResultStatus), }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login), global::AxibugProtobuf.Protobuf_Login.Parser, new[]{ "LoginType", "DeviceType", "Account", "Password" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status" }, null, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg), global::AxibugProtobuf.Protobuf_ChatMsg.Parser, new[]{ "ChatMsg" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg_RESP), global::AxibugProtobuf.Protobuf_ChatMsg_RESP.Parser, new[]{ "NickName", "ChatMsg", "Date" }, null, null, null, null) })); } #endregion @@ -59,6 +64,10 @@ namespace AxibugProtobuf { ///登录上行 | 下行 对应 Protobuf_Login | Protobuf_Login_RESP /// [pbr::OriginalName("CMD_LOGIN")] CmdLogin = 2001, + /// + ///登录上行 | 下行 对应 Protobuf_ChatMsg | Protobuf_ChatMsg_RESP + /// + [pbr::OriginalName("CMD_CHATMSG")] CmdChatmsg = 4001, } public enum ErrorCode { @@ -695,6 +704,440 @@ namespace AxibugProtobuf { } + /// + ///聊天 上行 + /// + public sealed partial class Protobuf_ChatMsg : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_ChatMsg()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufAuthReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg(Protobuf_ChatMsg other) : this() { + chatMsg_ = other.chatMsg_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg Clone() { + return new Protobuf_ChatMsg(this); + } + + /// Field number for the "ChatMsg" field. + public const int ChatMsgFieldNumber = 1; + private string chatMsg_ = ""; + /// + ///消息 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ChatMsg { + get { return chatMsg_; } + set { + chatMsg_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_ChatMsg); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_ChatMsg other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ChatMsg != other.ChatMsg) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ChatMsg.Length != 0) hash ^= ChatMsg.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (ChatMsg.Length != 0) { + output.WriteRawTag(10); + output.WriteString(ChatMsg); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (ChatMsg.Length != 0) { + output.WriteRawTag(10); + output.WriteString(ChatMsg); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ChatMsg.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ChatMsg); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_ChatMsg other) { + if (other == null) { + return; + } + if (other.ChatMsg.Length != 0) { + ChatMsg = other.ChatMsg; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + ChatMsg = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + ChatMsg = input.ReadString(); + break; + } + } + } + } + #endif + + } + + /// + ///聊天 下行 + /// + public sealed partial class Protobuf_ChatMsg_RESP : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_ChatMsg_RESP()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufAuthReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg_RESP() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg_RESP(Protobuf_ChatMsg_RESP other) : this() { + nickName_ = other.nickName_; + chatMsg_ = other.chatMsg_; + date_ = other.date_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg_RESP Clone() { + return new Protobuf_ChatMsg_RESP(this); + } + + /// Field number for the "NickName" field. + public const int NickNameFieldNumber = 1; + private string nickName_ = ""; + /// + ///昵称 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string NickName { + get { return nickName_; } + set { + nickName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "ChatMsg" field. + public const int ChatMsgFieldNumber = 2; + private string chatMsg_ = ""; + /// + ///消息 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ChatMsg { + get { return chatMsg_; } + set { + chatMsg_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "Date" field. + public const int DateFieldNumber = 3; + private long date_; + /// + ///消息 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Date { + get { return date_; } + set { + date_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_ChatMsg_RESP); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_ChatMsg_RESP other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (NickName != other.NickName) return false; + if (ChatMsg != other.ChatMsg) return false; + if (Date != other.Date) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (NickName.Length != 0) hash ^= NickName.GetHashCode(); + if (ChatMsg.Length != 0) hash ^= ChatMsg.GetHashCode(); + if (Date != 0L) hash ^= Date.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (NickName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(NickName); + } + if (ChatMsg.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ChatMsg); + } + if (Date != 0L) { + output.WriteRawTag(24); + output.WriteInt64(Date); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (NickName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(NickName); + } + if (ChatMsg.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ChatMsg); + } + if (Date != 0L) { + output.WriteRawTag(24); + output.WriteInt64(Date); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (NickName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(NickName); + } + if (ChatMsg.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ChatMsg); + } + if (Date != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Date); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_ChatMsg_RESP other) { + if (other == null) { + return; + } + if (other.NickName.Length != 0) { + NickName = other.NickName; + } + if (other.ChatMsg.Length != 0) { + ChatMsg = other.ChatMsg; + } + if (other.Date != 0L) { + Date = other.Date; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + NickName = input.ReadString(); + break; + } + case 18: { + ChatMsg = input.ReadString(); + break; + } + case 24: { + Date = input.ReadInt64(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + NickName = input.ReadString(); + break; + } + case 18: { + ChatMsg = input.ReadString(); + break; + } + case 24: { + Date = input.ReadInt64(); + break; + } + } + } + } + #endif + + } + #endregion } diff --git a/ProtobufCore/out/ProtobufAuth.cs b/ProtobufCore/out/ProtobufAuth.cs index e369d6f..2ab2650 100644 --- a/ProtobufCore/out/ProtobufAuth.cs +++ b/ProtobufCore/out/ProtobufAuth.cs @@ -30,20 +30,25 @@ namespace AxibugProtobuf { "b2J1Zi5EZXZpY2VUeXBlEg8KB0FjY291bnQYAyABKAkSEAoIUGFzc3dvcmQY", "BCABKAkifwoTUHJvdG9idWZfTG9naW5fUkVTUBINCgVUb2tlbhgBIAEoCRIV", "Cg1MYXN0TG9naW5EYXRlGAIgASgJEg8KB1JlZ0RhdGUYAyABKAkSMQoGU3Rh", - "dHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0dXMq", - "KwoJQ29tbWFuZElEEg4KCkNNRF9ERUZBVUwQABIOCglDTURfTE9HSU4Q0Q8q", - "KwoJRXJyb3JDb2RlEhAKDEVSUk9SX0RFRkFVTBAAEgwKCEVSUk9SX09LEAEq", - "PgoJTG9naW5UeXBlEg8KC0Jhc2VEZWZhdWx0EAASDgoKSGFvWXVlQXV0aBAB", - "EgcKA0JGMxADEgcKA0JGNBAEKksKCkRldmljZVR5cGUSFgoSRGV2aWNlVHlw", - "ZV9EZWZhdWx0EAASBgoCUEMQARILCgdBbmRyb2lkEAISBwoDSU9TEAMSBwoD", - "UFNWEAQqTgoRTG9naW5SZXN1bHRTdGF0dXMSIQodTG9naW5SZXN1bHRTdGF0", - "dXNfQmFzZURlZmF1bHQQABIGCgJPSxABEg4KCkFjY291bnRFcnIQAkICSAFi", - "BnByb3RvMw==")); + "dHVzGAQgASgOMiEuQXhpYnVnUHJvdG9idWYuTG9naW5SZXN1bHRTdGF0dXMi", + "IwoQUHJvdG9idWZfQ2hhdE1zZxIPCgdDaGF0TXNnGAEgASgJIkgKFVByb3Rv", + "YnVmX0NoYXRNc2dfUkVTUBIQCghOaWNrTmFtZRgBIAEoCRIPCgdDaGF0TXNn", + "GAIgASgJEgwKBERhdGUYAyABKAMqPQoJQ29tbWFuZElEEg4KCkNNRF9ERUZB", + "VUwQABIOCglDTURfTE9HSU4Q0Q8SEAoLQ01EX0NIQVRNU0cQoR8qKwoJRXJy", + "b3JDb2RlEhAKDEVSUk9SX0RFRkFVTBAAEgwKCEVSUk9SX09LEAEqPgoJTG9n", + "aW5UeXBlEg8KC0Jhc2VEZWZhdWx0EAASDgoKSGFvWXVlQXV0aBABEgcKA0JG", + "MxADEgcKA0JGNBAEKksKCkRldmljZVR5cGUSFgoSRGV2aWNlVHlwZV9EZWZh", + "dWx0EAASBgoCUEMQARILCgdBbmRyb2lkEAISBwoDSU9TEAMSBwoDUFNWEAQq", + "TgoRTG9naW5SZXN1bHRTdGF0dXMSIQodTG9naW5SZXN1bHRTdGF0dXNfQmFz", + "ZURlZmF1bHQQABIGCgJPSxABEg4KCkFjY291bnRFcnIQAkICSAFiBnByb3Rv", + "Mw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::AxibugProtobuf.CommandID), typeof(global::AxibugProtobuf.ErrorCode), typeof(global::AxibugProtobuf.LoginType), typeof(global::AxibugProtobuf.DeviceType), typeof(global::AxibugProtobuf.LoginResultStatus), }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login), global::AxibugProtobuf.Protobuf_Login.Parser, new[]{ "LoginType", "DeviceType", "Account", "Password" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status" }, null, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_Login_RESP), global::AxibugProtobuf.Protobuf_Login_RESP.Parser, new[]{ "Token", "LastLoginDate", "RegDate", "Status" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg), global::AxibugProtobuf.Protobuf_ChatMsg.Parser, new[]{ "ChatMsg" }, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::AxibugProtobuf.Protobuf_ChatMsg_RESP), global::AxibugProtobuf.Protobuf_ChatMsg_RESP.Parser, new[]{ "NickName", "ChatMsg", "Date" }, null, null, null, null) })); } #endregion @@ -59,6 +64,10 @@ namespace AxibugProtobuf { ///登录上行 | 下行 对应 Protobuf_Login | Protobuf_Login_RESP /// [pbr::OriginalName("CMD_LOGIN")] CmdLogin = 2001, + /// + ///登录上行 | 下行 对应 Protobuf_ChatMsg | Protobuf_ChatMsg_RESP + /// + [pbr::OriginalName("CMD_CHATMSG")] CmdChatmsg = 4001, } public enum ErrorCode { @@ -695,6 +704,440 @@ namespace AxibugProtobuf { } + /// + ///聊天 上行 + /// + public sealed partial class Protobuf_ChatMsg : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_ChatMsg()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufAuthReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg(Protobuf_ChatMsg other) : this() { + chatMsg_ = other.chatMsg_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg Clone() { + return new Protobuf_ChatMsg(this); + } + + /// Field number for the "ChatMsg" field. + public const int ChatMsgFieldNumber = 1; + private string chatMsg_ = ""; + /// + ///消息 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ChatMsg { + get { return chatMsg_; } + set { + chatMsg_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_ChatMsg); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_ChatMsg other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (ChatMsg != other.ChatMsg) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (ChatMsg.Length != 0) hash ^= ChatMsg.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (ChatMsg.Length != 0) { + output.WriteRawTag(10); + output.WriteString(ChatMsg); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (ChatMsg.Length != 0) { + output.WriteRawTag(10); + output.WriteString(ChatMsg); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (ChatMsg.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ChatMsg); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_ChatMsg other) { + if (other == null) { + return; + } + if (other.ChatMsg.Length != 0) { + ChatMsg = other.ChatMsg; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + ChatMsg = input.ReadString(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + ChatMsg = input.ReadString(); + break; + } + } + } + } + #endif + + } + + /// + ///聊天 下行 + /// + public sealed partial class Protobuf_ChatMsg_RESP : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Protobuf_ChatMsg_RESP()); + private pb::UnknownFieldSet _unknownFields; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::AxibugProtobuf.ProtobufAuthReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg_RESP() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg_RESP(Protobuf_ChatMsg_RESP other) : this() { + nickName_ = other.nickName_; + chatMsg_ = other.chatMsg_; + date_ = other.date_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Protobuf_ChatMsg_RESP Clone() { + return new Protobuf_ChatMsg_RESP(this); + } + + /// Field number for the "NickName" field. + public const int NickNameFieldNumber = 1; + private string nickName_ = ""; + /// + ///昵称 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string NickName { + get { return nickName_; } + set { + nickName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "ChatMsg" field. + public const int ChatMsgFieldNumber = 2; + private string chatMsg_ = ""; + /// + ///消息 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ChatMsg { + get { return chatMsg_; } + set { + chatMsg_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "Date" field. + public const int DateFieldNumber = 3; + private long date_; + /// + ///消息 + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long Date { + get { return date_; } + set { + date_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Protobuf_ChatMsg_RESP); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Protobuf_ChatMsg_RESP other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (NickName != other.NickName) return false; + if (ChatMsg != other.ChatMsg) return false; + if (Date != other.Date) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (NickName.Length != 0) hash ^= NickName.GetHashCode(); + if (ChatMsg.Length != 0) hash ^= ChatMsg.GetHashCode(); + if (Date != 0L) hash ^= Date.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (NickName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(NickName); + } + if (ChatMsg.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ChatMsg); + } + if (Date != 0L) { + output.WriteRawTag(24); + output.WriteInt64(Date); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (NickName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(NickName); + } + if (ChatMsg.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ChatMsg); + } + if (Date != 0L) { + output.WriteRawTag(24); + output.WriteInt64(Date); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (NickName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(NickName); + } + if (ChatMsg.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ChatMsg); + } + if (Date != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(Date); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Protobuf_ChatMsg_RESP other) { + if (other == null) { + return; + } + if (other.NickName.Length != 0) { + NickName = other.NickName; + } + if (other.ChatMsg.Length != 0) { + ChatMsg = other.ChatMsg; + } + if (other.Date != 0L) { + Date = other.Date; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + NickName = input.ReadString(); + break; + } + case 18: { + ChatMsg = input.ReadString(); + break; + } + case 24: { + Date = input.ReadInt64(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + NickName = input.ReadString(); + break; + } + case 18: { + ChatMsg = input.ReadString(); + break; + } + case 24: { + Date = input.ReadInt64(); + break; + } + } + } + } + #endif + + } + #endregion } diff --git a/ProtobufCore/proto/protobuf_Auth.proto b/ProtobufCore/proto/protobuf_Auth.proto index 4ad7b40..5298c59 100644 --- a/ProtobufCore/proto/protobuf_Auth.proto +++ b/ProtobufCore/proto/protobuf_Auth.proto @@ -7,6 +7,8 @@ enum CommandID CMD_DEFAUL = 0;//缺省不使用 CMD_LOGIN = 2001; //登录上行 | 下行 对应 Protobuf_Login | Protobuf_Login_RESP + + CMD_CHATMSG = 4001; //登录上行 | 下行 对应 Protobuf_ChatMsg | Protobuf_ChatMsg_RESP } enum ErrorCode @@ -55,4 +57,19 @@ message Protobuf_Login_RESP string LastLoginDate = 2;//上次登录时间(只用于呈现的字符串,若界面需求需要) string RegDate = 3;//注册时间(只用于呈现的字符串,若界面需求需要) LoginResultStatus Status = 4;//账号状态 (预留) [1]正常[0]被禁封 +} + + +//聊天 上行 +message Protobuf_ChatMsg +{ + string ChatMsg = 1;//消息 +} + +//聊天 下行 +message Protobuf_ChatMsg_RESP +{ + string NickName = 1;//昵称 + string ChatMsg = 2;//消息 + int64 Date = 3;//消息 } \ No newline at end of file diff --git a/Server/Program.cs b/Server/Program.cs index c344a57..ee74c9a 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -10,7 +10,7 @@ while (true) switch (Command) { case "list": - Console.WriteLine("当前在线:" + ServerManager.g_ClientMgr.ClientList.Count()); + Console.WriteLine("当前在线:" + ServerManager.g_ClientMgr.GetOnlineClient()); break; default: Console.WriteLine("未知命令" + CommandStr); diff --git a/ServerCore/Common/Helper.cs b/ServerCore/Common/Helper.cs new file mode 100644 index 0000000..2cf4cfe --- /dev/null +++ b/ServerCore/Common/Helper.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ServerCore.Common +{ + public static class Helper + { + public static long GetNowTimeStamp() + { + return GetTimeStamp(DateTime.Now); + } + + /// + /// 获取时间戳 + /// + /// + public static long GetTimeStamp(DateTime dt) + { + TimeSpan ts = dt - new DateTime(1970, 1, 1, 0, 0, 0, 0); + return Convert.ToInt64(ts.TotalSeconds); + } + } +} diff --git a/ServerCore/Manager/ChatManager.cs b/ServerCore/Manager/ChatManager.cs new file mode 100644 index 0000000..762834d --- /dev/null +++ b/ServerCore/Manager/ChatManager.cs @@ -0,0 +1,23 @@ +using AxibugProtobuf; +using ServerCore.Common; +using System.Net.Sockets; + +namespace ServerCore +{ + public class ChatManager + { + public void RecvPlayerChatMsg(Socket sk, byte[] reqData) + { + ClientInfo _c = ServerManager.g_ClientMgr.GetClientForSocket(sk); + ServerManager.g_Log.Debug("收到新的登录请求"); + Protobuf_ChatMsg msg = NetBase.DeSerizlize(reqData); + byte[] respData = NetBase.Serizlize(new Protobuf_ChatMsg_RESP() + { + ChatMsg = msg.ChatMsg, + NickName = _c.Account, + Date = Helper.GetNowTimeStamp() + }); + ServerManager.g_ClientMgr.ClientSendALL((int)CommandID.CmdChatmsg, (int)ErrorCode.ErrorOk, respData); + } + } +} \ No newline at end of file diff --git a/ServerCore/Manager/ClientManager.cs b/ServerCore/Manager/ClientManager.cs index 1ccb9d3..7a6f31c 100644 --- a/ServerCore/Manager/ClientManager.cs +++ b/ServerCore/Manager/ClientManager.cs @@ -1,4 +1,5 @@ -using System.Net.Sockets; +using AxibugProtobuf; +using System.Net.Sockets; using System.Timers; namespace ServerCore @@ -6,6 +7,7 @@ namespace ServerCore public class ClientInfo { public long UID { get; set; } + public string Account { get; set; } public Socket _socket { get; set; } public bool IsOffline { get; set; } = false; public DateTime LogOutDT { get; set; } @@ -13,14 +15,14 @@ namespace ServerCore public class ClientManager { - public List ClientList = new List(); - public Dictionary _DictSocketClient = new Dictionary(); - public Dictionary _DictUIDClient = new Dictionary(); - public long TestUIDSeed = 0; - + private List ClientList = new List(); + private Dictionary _DictSocketClient = new Dictionary(); + private Dictionary _DictUIDClient = new Dictionary(); + private long TestUIDSeed = 0; + private System.Timers.Timer _ClientCheckTimer; private long _RemoveOfflineCacheMin; - public void Init(long ticktime,long RemoveOfflineCacheMin) + public void Init(long ticktime, long RemoveOfflineCacheMin) { //换算成毫秒 _RemoveOfflineCacheMin = RemoveOfflineCacheMin * 1000; @@ -35,7 +37,7 @@ namespace ServerCore { return ++TestUIDSeed; } - + private void ClientCheckClearOffline_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { DateTime CheckDT = DateTime.Now.AddMinutes(-1 * _RemoveOfflineCacheMin); @@ -54,7 +56,7 @@ namespace ServerCore //通用处理 #region clientlist 处理 - public ClientInfo JoinNewClient(Socket _socket) + public ClientInfo JoinNewClient(Protobuf_Login data, Socket _socket) { //也许这个函数需加lock @@ -62,7 +64,7 @@ namespace ServerCore //如果连接还在 if (cinfo != null) { - cinfo.IsOffline = true; + cinfo.IsOffline = false; } else { @@ -70,7 +72,8 @@ namespace ServerCore { UID = GetNextUID(), _socket = _socket, - IsOffline = true, + Account = data.Account, + IsOffline = false, }; AddClient(cinfo); } @@ -85,7 +88,7 @@ namespace ServerCore { try { - Console.WriteLine("追加连接玩家 UID=>" + clientInfo.UID); + Console.WriteLine("追加连接玩家 UID=>" + clientInfo.UID + " | " + clientInfo.Account); lock (ClientList) { _DictUIDClient.Add(clientInfo.UID, clientInfo); @@ -98,7 +101,7 @@ namespace ServerCore ex.ToString(); } } - + /// /// 清理连接 /// @@ -107,12 +110,12 @@ namespace ServerCore { lock (ClientList) { - if(_DictUIDClient.ContainsKey(client.UID)) + if (_DictUIDClient.ContainsKey(client.UID)) _DictUIDClient.Remove(client.UID); if (_DictSocketClient.ContainsKey(client._socket)) _DictSocketClient.Remove(client._socket); - + ClientList.Remove(client); } } @@ -142,7 +145,7 @@ namespace ServerCore if (!_DictSocketClient.ContainsKey(sk)) return; - Console.WriteLine("标记玩家UID"+ _DictSocketClient[sk].UID+ "为离线"); + Console.WriteLine("标记玩家UID" + _DictSocketClient[sk].UID + "为离线"); _DictSocketClient[sk].IsOffline = true; _DictSocketClient[sk].LogOutDT = DateTime.Now; } @@ -157,6 +160,10 @@ namespace ServerCore #endregion + public void ClientSendALL(int CMDID, int ERRCODE, byte[] data) + { + ClientSend(ClientList,CMDID, ERRCODE, data); + } /// /// 给一组用户发送数据 @@ -194,5 +201,10 @@ namespace ServerCore return; ServerManager.g_SocketMgr.SendToSocket(_c._socket, CMDID, ERRCODE, data); } + + public int GetOnlineClient() + { + return ClientList.Where(w => !w.IsOffline).Count(); + } } } diff --git a/ServerCore/Manager/LoginManager.cs b/ServerCore/Manager/LoginManager.cs index da00262..2f5db16 100644 --- a/ServerCore/Manager/LoginManager.cs +++ b/ServerCore/Manager/LoginManager.cs @@ -9,7 +9,7 @@ namespace ServerCore { ServerManager.g_Log.Debug("收到新的登录请求"); Protobuf_Login msg = NetBase.DeSerizlize(reqData); - ClientInfo cinfo = ServerManager.g_ClientMgr.JoinNewClient(_socket); + ClientInfo cinfo = ServerManager.g_ClientMgr.JoinNewClient(msg,_socket); byte[] respData = NetBase.Serizlize(new Protobuf_Login_RESP() { diff --git a/ServerCore/Manager/ServerManager.cs b/ServerCore/Manager/ServerManager.cs index e2d2466..7c4bd04 100644 --- a/ServerCore/Manager/ServerManager.cs +++ b/ServerCore/Manager/ServerManager.cs @@ -7,6 +7,7 @@ namespace ServerCore public static ClientManager g_ClientMgr; public static LogManager g_Log; public static LoginManager g_Login; + public static ChatManager g_Chat; public static IOCPNetWork g_SocketMgr; public static void InitServer(int port) @@ -14,6 +15,7 @@ namespace ServerCore g_ClientMgr = new ClientManager(); g_Log = new LogManager(); g_Login = new LoginManager(); + g_Chat = new ChatManager(); g_SocketMgr = new IOCPNetWork(1024, 1024); g_SocketMgr.Init(); g_SocketMgr.Start(new IPEndPoint(IPAddress.Any.Address, port)); diff --git a/ServerCore/NetWork/IOCPNetWork.cs b/ServerCore/NetWork/IOCPNetWork.cs index 2fedb6d..f60858a 100644 --- a/ServerCore/NetWork/IOCPNetWork.cs +++ b/ServerCore/NetWork/IOCPNetWork.cs @@ -47,7 +47,8 @@ namespace ServerCore { switch ((CommandID)CMDID) { - case CommandID.CmdLogin:ServerManager.g_Login.UserLogin(sk, data); break; + case CommandID.CmdLogin: ServerManager.g_Login.UserLogin(sk, data); break; + case CommandID.CmdChatmsg: ServerManager.g_Chat.RecvPlayerChatMsg(sk, data);break; } } catch (Exception ex)