底层网络库 脱离protobuf 至此无任何依赖
This commit is contained in:
parent
52a24f979b
commit
f204fe1deb
49
NetLib/HaoYueNet.ClientNetwork/BaseData.cs
Normal file
49
NetLib/HaoYueNet.ClientNetwork/BaseData.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HaoYueNet.ClientNetwork
|
||||||
|
{
|
||||||
|
public static class BaseData
|
||||||
|
{
|
||||||
|
public static class HunterNet_S2C
|
||||||
|
{
|
||||||
|
public static byte[] CreatePkgData(UInt16 CmdID, UInt16 Error, byte[] data)
|
||||||
|
{
|
||||||
|
byte[] newdata = new byte[2 + 2 + data.Length];
|
||||||
|
BitConverter.GetBytes(CmdID).CopyTo(newdata, 0);
|
||||||
|
BitConverter.GetBytes(Error).CopyTo(newdata, 2);
|
||||||
|
Array.Copy(data, 0, newdata, 4, data.Length);
|
||||||
|
return newdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AnalysisPkgData(byte[] srcdata,out UInt16 CmdID,out UInt16 Error,out byte[] data)
|
||||||
|
{
|
||||||
|
data = new byte[srcdata.Length - 2 - 2];
|
||||||
|
CmdID = BitConverter.ToUInt16(srcdata, 0);
|
||||||
|
Error = BitConverter.ToUInt16(srcdata, 2);
|
||||||
|
Array.Copy(srcdata, 4, data, 0, data.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class HunterNet_C2S
|
||||||
|
{
|
||||||
|
public static byte[] CreatePkgData(UInt16 CmdID, byte[] data)
|
||||||
|
{
|
||||||
|
byte[] newdata = new byte[2 + data.Length];
|
||||||
|
BitConverter.GetBytes(CmdID).CopyTo(newdata, 0);
|
||||||
|
Array.Copy(data, 0, newdata, 2, data.Length);
|
||||||
|
return newdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AnalysisPkgData(byte[] srcdata, out UInt16 CmdID, out byte[] data)
|
||||||
|
{
|
||||||
|
data = new byte[srcdata.Length - 2];
|
||||||
|
CmdID = BitConverter.ToUInt16(srcdata, 0);
|
||||||
|
Array.Copy(srcdata, 2, data, 0, data.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,10 +6,4 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Google.Protobuf">
|
|
||||||
<HintPath>..\Google.Protobuf.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using Google.Protobuf;
|
//using HunterProtobufCore;
|
||||||
using HunterProtobufCore;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using static HaoYueNet.ClientNetwork.BaseData;
|
||||||
|
|
||||||
namespace HaoYueNet.ClientNetwork
|
namespace HaoYueNet.ClientNetwork
|
||||||
{
|
{
|
||||||
@ -168,10 +168,13 @@ namespace HaoYueNet.ClientNetwork
|
|||||||
public void SendToServer(int CMDID,byte[] data)
|
public void SendToServer(int CMDID,byte[] data)
|
||||||
{
|
{
|
||||||
//LogOut("准备数据 CMDID=> "+CMDID);
|
//LogOut("准备数据 CMDID=> "+CMDID);
|
||||||
|
/*
|
||||||
HunterNet_C2S _c2sdata = new HunterNet_C2S();
|
HunterNet_C2S _c2sdata = new HunterNet_C2S();
|
||||||
_c2sdata.HunterNetCoreCmdID = CMDID;
|
_c2sdata.HunterNetCoreCmdID = CMDID;
|
||||||
_c2sdata.HunterNetCoreData = ByteString.CopyFrom(data);
|
_c2sdata.HunterNetCoreData = ByteString.CopyFrom(data);
|
||||||
byte[] _finaldata = Serizlize(_c2sdata);
|
byte[] _finaldata = Serizlize(_c2sdata);
|
||||||
|
*/
|
||||||
|
byte[] _finaldata = HunterNet_C2S.CreatePkgData((ushort)CMDID, data);
|
||||||
SendToSocket(_finaldata);
|
SendToSocket(_finaldata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,9 +247,14 @@ namespace HaoYueNet.ClientNetwork
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
HunterNet_S2C _c2s = DeSerizlize<HunterNet_S2C>(data);
|
HunterNet_S2C _c2s = DeSerizlize<HunterNet_S2C>(data);
|
||||||
|
|
||||||
OnReceiveData(_c2s.HunterNetCoreCmdID, _c2s.HunterNetCoreERRORCode, _c2s.HunterNetCoreData.ToArray());
|
OnReceiveData(_c2s.HunterNetCoreCmdID, _c2s.HunterNetCoreERRORCode, _c2s.HunterNetCoreData.ToArray());
|
||||||
|
*/
|
||||||
|
|
||||||
|
HunterNet_S2C.AnalysisPkgData(data, out ushort CmdID, out ushort Error, out byte[] resultdata);
|
||||||
|
OnReceiveData(CmdID, Error, resultdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -352,18 +360,6 @@ namespace HaoYueNet.ClientNetwork
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] Serizlize(IMessage msg)
|
|
||||||
{
|
|
||||||
return msg.ToByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T DeSerizlize<T>(byte[] bytes)
|
|
||||||
{
|
|
||||||
var msgType = typeof(T);
|
|
||||||
object msg = Activator.CreateInstance(msgType);
|
|
||||||
((IMessage)msg).MergeFrom(bytes);
|
|
||||||
return (T)msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LogOut(string Msg)
|
public void LogOut(string Msg)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
using Google.Protobuf;
|
using System.Net;
|
||||||
using HunterProtobufCore;
|
|
||||||
using System.Net;
|
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using static HaoYueNet.ClientNetwork.BaseData;
|
||||||
|
|
||||||
namespace HaoYueNet.ClientNetwork
|
namespace HaoYueNet.ClientNetwork
|
||||||
{
|
{
|
||||||
@ -165,11 +164,13 @@ namespace HaoYueNet.ClientNetwork
|
|||||||
public void SendToSocket(int CMDID, int ERRCODE, byte[] data)
|
public void SendToSocket(int CMDID, int ERRCODE, byte[] data)
|
||||||
{
|
{
|
||||||
//LogOut("准备数据 CMDID=> "+CMDID);
|
//LogOut("准备数据 CMDID=> "+CMDID);
|
||||||
HunterNet_S2C _s2sdata = new HunterNet_S2C();
|
/*HunterNet_S2C _s2sdata = new HunterNet_S2C();
|
||||||
_s2sdata.HunterNetCoreCmdID = CMDID;
|
_s2sdata.HunterNetCoreCmdID = CMDID;
|
||||||
_s2sdata.HunterNetCoreERRORCode = ERRCODE;
|
_s2sdata.HunterNetCoreERRORCode = ERRCODE;
|
||||||
_s2sdata.HunterNetCoreData = ByteString.CopyFrom(data);
|
_s2sdata.HunterNetCoreData = ByteString.CopyFrom(data);
|
||||||
byte[] _finaldata = Serizlize(_s2sdata);
|
byte[] _finaldata = Serizlize(_s2sdata);*/
|
||||||
|
|
||||||
|
byte[] _finaldata = HunterNet_S2C.CreatePkgData((ushort)CMDID, (ushort)ERRCODE, data);
|
||||||
SendToSocket(_finaldata);
|
SendToSocket(_finaldata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,9 +247,12 @@ namespace HaoYueNet.ClientNetwork
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
HunterNet_S2C _c2s = DeSerizlize<HunterNet_S2C>(data);
|
HunterNet_S2C _c2s = DeSerizlize<HunterNet_S2C>(data);
|
||||||
|
|
||||||
OnDataCallBack(_c2s.HunterNetCoreCmdID, _c2s.HunterNetCoreERRORCode, _c2s.HunterNetCoreData.ToArray());
|
OnDataCallBack(_c2s.HunterNetCoreCmdID, _c2s.HunterNetCoreERRORCode, _c2s.HunterNetCoreData.ToArray());
|
||||||
|
*/
|
||||||
|
HunterNet_S2C.AnalysisPkgData(data, out ushort CmdID, out ushort Error, out byte[] resultdata);
|
||||||
|
OnDataCallBack(CmdID, Error, resultdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryStream memoryStream = new MemoryStream();//开辟一个内存流
|
MemoryStream memoryStream = new MemoryStream();//开辟一个内存流
|
||||||
@ -354,19 +358,6 @@ namespace HaoYueNet.ClientNetwork
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] Serizlize(IMessage msg)
|
|
||||||
{
|
|
||||||
return msg.ToByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T DeSerizlize<T>(byte[] bytes)
|
|
||||||
{
|
|
||||||
var msgType = typeof(T);
|
|
||||||
object msg = Activator.CreateInstance(msgType);
|
|
||||||
((IMessage)msg).MergeFrom(bytes);
|
|
||||||
return (T)msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LogOut(string Msg)
|
public void LogOut(string Msg)
|
||||||
{
|
{
|
||||||
//Console.WriteLine(Msg);
|
//Console.WriteLine(Msg);
|
||||||
|
@ -1,505 +0,0 @@
|
|||||||
// <auto-generated>
|
|
||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
// source: protobuf_HunterNetCore.proto
|
|
||||||
// </auto-generated>
|
|
||||||
#pragma warning disable 1591, 0612, 3021
|
|
||||||
#region Designer generated code
|
|
||||||
|
|
||||||
using pb = global::Google.Protobuf;
|
|
||||||
using pbr = global::Google.Protobuf.Reflection;
|
|
||||||
namespace HunterProtobufCore
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>Holder for reflection information generated from protobuf_HunterNetCore.proto</summary>
|
|
||||||
public static partial class ProtobufHunterNetCoreReflection {
|
|
||||||
|
|
||||||
#region Descriptor
|
|
||||||
/// <summary>File descriptor for protobuf_HunterNetCore.proto</summary>
|
|
||||||
public static pbr::FileDescriptor Descriptor {
|
|
||||||
get { return descriptor; }
|
|
||||||
}
|
|
||||||
private static pbr::FileDescriptor descriptor;
|
|
||||||
|
|
||||||
static ProtobufHunterNetCoreReflection() {
|
|
||||||
byte[] descriptorData = global::System.Convert.FromBase64String(
|
|
||||||
string.Concat(
|
|
||||||
"Chxwcm90b2J1Zl9IdW50ZXJOZXRDb3JlLnByb3RvEhJIdW50ZXJQcm90b2J1",
|
|
||||||
"ZkNvcmUiSAoNSHVudGVyTmV0X0MyUxIbChNIdW50ZXJOZXRDb3JlX0NtZElE",
|
|
||||||
"GAEgASgFEhoKEkh1bnRlck5ldENvcmVfRGF0YRgCIAEoDCJpCg1IdW50ZXJO",
|
|
||||||
"ZXRfUzJDEhsKE0h1bnRlck5ldENvcmVfQ21kSUQYASABKAUSHwoXSHVudGVy",
|
|
||||||
"TmV0Q29yZV9FUlJPUkNvZGUYAiABKAUSGgoSSHVudGVyTmV0Q29yZV9EYXRh",
|
|
||||||
"GAMgASgMQgJIAWIGcHJvdG8z"));
|
|
||||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
|
||||||
new pbr::FileDescriptor[] { },
|
|
||||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
|
||||||
new pbr::GeneratedClrTypeInfo(typeof(global::HunterProtobufCore.HunterNet_C2S), global::HunterProtobufCore.HunterNet_C2S.Parser, new[]{ "HunterNetCoreCmdID", "HunterNetCoreData" }, null, null, null, null),
|
|
||||||
new pbr::GeneratedClrTypeInfo(typeof(global::HunterProtobufCore.HunterNet_S2C), global::HunterProtobufCore.HunterNet_S2C.Parser, new[]{ "HunterNetCoreCmdID", "HunterNetCoreERRORCode", "HunterNetCoreData" }, null, null, null, null)
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
|
||||||
#region Messages
|
|
||||||
/// <summary>
|
|
||||||
///上行
|
|
||||||
/// </summary>
|
|
||||||
public sealed partial class HunterNet_C2S : pb::IMessage<HunterNet_C2S>
|
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
|
||||||
, pb::IBufferMessage
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
private static readonly pb::MessageParser<HunterNet_C2S> _parser = new pb::MessageParser<HunterNet_C2S>(() => new HunterNet_C2S());
|
|
||||||
private pb::UnknownFieldSet _unknownFields;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public static pb::MessageParser<HunterNet_C2S> Parser { get { return _parser; } }
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public static pbr::MessageDescriptor Descriptor {
|
|
||||||
get { return global::HunterProtobufCore.ProtobufHunterNetCoreReflection.Descriptor.MessageTypes[0]; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
|
||||||
get { return Descriptor; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_C2S() {
|
|
||||||
OnConstruction();
|
|
||||||
}
|
|
||||||
|
|
||||||
partial void OnConstruction();
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_C2S(HunterNet_C2S other) : this() {
|
|
||||||
hunterNetCoreCmdID_ = other.hunterNetCoreCmdID_;
|
|
||||||
hunterNetCoreData_ = other.hunterNetCoreData_;
|
|
||||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_C2S Clone() {
|
|
||||||
return new HunterNet_C2S(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_CmdID" field.</summary>
|
|
||||||
public const int HunterNetCoreCmdIDFieldNumber = 1;
|
|
||||||
private int hunterNetCoreCmdID_;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public int HunterNetCoreCmdID {
|
|
||||||
get { return hunterNetCoreCmdID_; }
|
|
||||||
set {
|
|
||||||
hunterNetCoreCmdID_ = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_Data" field.</summary>
|
|
||||||
public const int HunterNetCoreDataFieldNumber = 2;
|
|
||||||
private pb::ByteString hunterNetCoreData_ = pb::ByteString.Empty;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public pb::ByteString HunterNetCoreData {
|
|
||||||
get { return hunterNetCoreData_; }
|
|
||||||
set {
|
|
||||||
hunterNetCoreData_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public override bool Equals(object other) {
|
|
||||||
return Equals(other as HunterNet_C2S);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public bool Equals(HunterNet_C2S other) {
|
|
||||||
if (ReferenceEquals(other, null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (ReferenceEquals(other, this)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (HunterNetCoreCmdID != other.HunterNetCoreCmdID) return false;
|
|
||||||
if (HunterNetCoreData != other.HunterNetCoreData) return false;
|
|
||||||
return Equals(_unknownFields, other._unknownFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public override int GetHashCode() {
|
|
||||||
int hash = 1;
|
|
||||||
if (HunterNetCoreCmdID != 0) hash ^= HunterNetCoreCmdID.GetHashCode();
|
|
||||||
if (HunterNetCoreData.Length != 0) hash ^= HunterNetCoreData.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 (HunterNetCoreCmdID != 0) {
|
|
||||||
output.WriteRawTag(8);
|
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
output.WriteRawTag(18);
|
|
||||||
output.WriteBytes(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
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 (HunterNetCoreCmdID != 0) {
|
|
||||||
output.WriteRawTag(8);
|
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
output.WriteRawTag(18);
|
|
||||||
output.WriteBytes(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
if (_unknownFields != null) {
|
|
||||||
_unknownFields.WriteTo(ref output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public int CalculateSize() {
|
|
||||||
int size = 0;
|
|
||||||
if (HunterNetCoreCmdID != 0) {
|
|
||||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
size += 1 + pb::CodedOutputStream.ComputeBytesSize(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
if (_unknownFields != null) {
|
|
||||||
size += _unknownFields.CalculateSize();
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public void MergeFrom(HunterNet_C2S other) {
|
|
||||||
if (other == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (other.HunterNetCoreCmdID != 0) {
|
|
||||||
HunterNetCoreCmdID = other.HunterNetCoreCmdID;
|
|
||||||
}
|
|
||||||
if (other.HunterNetCoreData.Length != 0) {
|
|
||||||
HunterNetCoreData = other.HunterNetCoreData;
|
|
||||||
}
|
|
||||||
_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 8: {
|
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 18: {
|
|
||||||
HunterNetCoreData = input.ReadBytes();
|
|
||||||
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 8: {
|
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 18: {
|
|
||||||
HunterNetCoreData = input.ReadBytes();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///下行
|
|
||||||
/// </summary>
|
|
||||||
public sealed partial class HunterNet_S2C : pb::IMessage<HunterNet_S2C>
|
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
|
||||||
, pb::IBufferMessage
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
private static readonly pb::MessageParser<HunterNet_S2C> _parser = new pb::MessageParser<HunterNet_S2C>(() => new HunterNet_S2C());
|
|
||||||
private pb::UnknownFieldSet _unknownFields;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public static pb::MessageParser<HunterNet_S2C> Parser { get { return _parser; } }
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public static pbr::MessageDescriptor Descriptor {
|
|
||||||
get { return global::HunterProtobufCore.ProtobufHunterNetCoreReflection.Descriptor.MessageTypes[1]; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
|
||||||
get { return Descriptor; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_S2C() {
|
|
||||||
OnConstruction();
|
|
||||||
}
|
|
||||||
|
|
||||||
partial void OnConstruction();
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_S2C(HunterNet_S2C other) : this() {
|
|
||||||
hunterNetCoreCmdID_ = other.hunterNetCoreCmdID_;
|
|
||||||
hunterNetCoreERRORCode_ = other.hunterNetCoreERRORCode_;
|
|
||||||
hunterNetCoreData_ = other.hunterNetCoreData_;
|
|
||||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_S2C Clone() {
|
|
||||||
return new HunterNet_S2C(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_CmdID" field.</summary>
|
|
||||||
public const int HunterNetCoreCmdIDFieldNumber = 1;
|
|
||||||
private int hunterNetCoreCmdID_;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public int HunterNetCoreCmdID {
|
|
||||||
get { return hunterNetCoreCmdID_; }
|
|
||||||
set {
|
|
||||||
hunterNetCoreCmdID_ = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_ERRORCode" field.</summary>
|
|
||||||
public const int HunterNetCoreERRORCodeFieldNumber = 2;
|
|
||||||
private int hunterNetCoreERRORCode_;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public int HunterNetCoreERRORCode {
|
|
||||||
get { return hunterNetCoreERRORCode_; }
|
|
||||||
set {
|
|
||||||
hunterNetCoreERRORCode_ = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_Data" field.</summary>
|
|
||||||
public const int HunterNetCoreDataFieldNumber = 3;
|
|
||||||
private pb::ByteString hunterNetCoreData_ = pb::ByteString.Empty;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public pb::ByteString HunterNetCoreData {
|
|
||||||
get { return hunterNetCoreData_; }
|
|
||||||
set {
|
|
||||||
hunterNetCoreData_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public override bool Equals(object other) {
|
|
||||||
return Equals(other as HunterNet_S2C);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public bool Equals(HunterNet_S2C other) {
|
|
||||||
if (ReferenceEquals(other, null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (ReferenceEquals(other, this)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (HunterNetCoreCmdID != other.HunterNetCoreCmdID) return false;
|
|
||||||
if (HunterNetCoreERRORCode != other.HunterNetCoreERRORCode) return false;
|
|
||||||
if (HunterNetCoreData != other.HunterNetCoreData) return false;
|
|
||||||
return Equals(_unknownFields, other._unknownFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public override int GetHashCode() {
|
|
||||||
int hash = 1;
|
|
||||||
if (HunterNetCoreCmdID != 0) hash ^= HunterNetCoreCmdID.GetHashCode();
|
|
||||||
if (HunterNetCoreERRORCode != 0) hash ^= HunterNetCoreERRORCode.GetHashCode();
|
|
||||||
if (HunterNetCoreData.Length != 0) hash ^= HunterNetCoreData.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 (HunterNetCoreCmdID != 0) {
|
|
||||||
output.WriteRawTag(8);
|
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreERRORCode != 0) {
|
|
||||||
output.WriteRawTag(16);
|
|
||||||
output.WriteInt32(HunterNetCoreERRORCode);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
output.WriteRawTag(26);
|
|
||||||
output.WriteBytes(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
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 (HunterNetCoreCmdID != 0) {
|
|
||||||
output.WriteRawTag(8);
|
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreERRORCode != 0) {
|
|
||||||
output.WriteRawTag(16);
|
|
||||||
output.WriteInt32(HunterNetCoreERRORCode);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
output.WriteRawTag(26);
|
|
||||||
output.WriteBytes(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
if (_unknownFields != null) {
|
|
||||||
_unknownFields.WriteTo(ref output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public int CalculateSize() {
|
|
||||||
int size = 0;
|
|
||||||
if (HunterNetCoreCmdID != 0) {
|
|
||||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreERRORCode != 0) {
|
|
||||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreERRORCode);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
size += 1 + pb::CodedOutputStream.ComputeBytesSize(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
if (_unknownFields != null) {
|
|
||||||
size += _unknownFields.CalculateSize();
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public void MergeFrom(HunterNet_S2C other) {
|
|
||||||
if (other == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (other.HunterNetCoreCmdID != 0) {
|
|
||||||
HunterNetCoreCmdID = other.HunterNetCoreCmdID;
|
|
||||||
}
|
|
||||||
if (other.HunterNetCoreERRORCode != 0) {
|
|
||||||
HunterNetCoreERRORCode = other.HunterNetCoreERRORCode;
|
|
||||||
}
|
|
||||||
if (other.HunterNetCoreData.Length != 0) {
|
|
||||||
HunterNetCoreData = other.HunterNetCoreData;
|
|
||||||
}
|
|
||||||
_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 8: {
|
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 16: {
|
|
||||||
HunterNetCoreERRORCode = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 26: {
|
|
||||||
HunterNetCoreData = input.ReadBytes();
|
|
||||||
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 8: {
|
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 16: {
|
|
||||||
HunterNetCoreERRORCode = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 26: {
|
|
||||||
HunterNetCoreData = input.ReadBytes();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Designer generated code
|
|
49
NetLib/HaoYueNet.ClientNetworkNet4x/BaseData.cs
Normal file
49
NetLib/HaoYueNet.ClientNetworkNet4x/BaseData.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HaoYueNet.ClientNetworkNet4x
|
||||||
|
{
|
||||||
|
public static class BaseData
|
||||||
|
{
|
||||||
|
public static class HunterNet_S2C
|
||||||
|
{
|
||||||
|
public static byte[] CreatePkgData(UInt16 CmdID, UInt16 Error, byte[] data)
|
||||||
|
{
|
||||||
|
byte[] newdata = new byte[2 + 2 + data.Length];
|
||||||
|
BitConverter.GetBytes(CmdID).CopyTo(newdata, 0);
|
||||||
|
BitConverter.GetBytes(Error).CopyTo(newdata, 2);
|
||||||
|
Array.Copy(data, 0, newdata, 4, data.Length);
|
||||||
|
return newdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AnalysisPkgData(byte[] srcdata,out UInt16 CmdID,out UInt16 Error,out byte[] data)
|
||||||
|
{
|
||||||
|
data = new byte[srcdata.Length - 2 - 2];
|
||||||
|
CmdID = BitConverter.ToUInt16(srcdata, 0);
|
||||||
|
Error = BitConverter.ToUInt16(srcdata, 2);
|
||||||
|
Array.Copy(srcdata, 4, data, 0, data.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class HunterNet_C2S
|
||||||
|
{
|
||||||
|
public static byte[] CreatePkgData(UInt16 CmdID, byte[] data)
|
||||||
|
{
|
||||||
|
byte[] newdata = new byte[2 + data.Length];
|
||||||
|
BitConverter.GetBytes(CmdID).CopyTo(newdata, 0);
|
||||||
|
Array.Copy(data, 0, newdata, 2, data.Length);
|
||||||
|
return newdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AnalysisPkgData(byte[] srcdata, out UInt16 CmdID, out byte[] data)
|
||||||
|
{
|
||||||
|
data = new byte[srcdata.Length - 2];
|
||||||
|
CmdID = BitConverter.ToUInt16(srcdata, 0);
|
||||||
|
Array.Copy(srcdata, 2, data, 0, data.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -32,40 +32,18 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Google.Protobuf">
|
|
||||||
<HintPath>..\Google.Protobuf.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Numerics" />
|
|
||||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="BaseData.cs" />
|
||||||
<Compile Include="NetworkHelperCore.cs" />
|
<Compile Include="NetworkHelperCore.cs" />
|
||||||
<Compile Include="NetworkHelperP2PCore.cs" />
|
<Compile Include="NetworkHelperP2PCore.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ProtobufHunterNetCore.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
<None Include="packages.config" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
@ -1,11 +1,9 @@
|
|||||||
using Google.Protobuf;
|
using System;
|
||||||
using HunterProtobufCore;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using static HaoYueNet.ClientNetworkNet4x.BaseData;
|
||||||
|
|
||||||
namespace HaoYueNet.ClientNetworkNet4x
|
namespace HaoYueNet.ClientNetworkNet4x
|
||||||
{
|
{
|
||||||
@ -40,9 +38,11 @@ namespace HaoYueNet.ClientNetworkNet4x
|
|||||||
|
|
||||||
private System.Timers.Timer _heartTimer;
|
private System.Timers.Timer _heartTimer;
|
||||||
|
|
||||||
public void Init(string IP, int port, bool bBindReuseAddress = false, int bBindport = 0)
|
public static string LastConnectIP;
|
||||||
{
|
public static int LastConnectPort;
|
||||||
|
|
||||||
|
public bool Init(string IP, int port, bool bBindReuseAddress = false, int bBindport = 0)
|
||||||
|
{
|
||||||
LogOut("==>初始化网络核心");
|
LogOut("==>初始化网络核心");
|
||||||
|
|
||||||
RevIndex = MaxRevIndexNum;
|
RevIndex = MaxRevIndexNum;
|
||||||
@ -55,10 +55,12 @@ namespace HaoYueNet.ClientNetworkNet4x
|
|||||||
IPEndPoint ipe = new IPEndPoint(IPAddress.Any, Convert.ToInt32(bBindport));
|
IPEndPoint ipe = new IPEndPoint(IPAddress.Any, Convert.ToInt32(bBindport));
|
||||||
client.Bind(ipe);
|
client.Bind(ipe);
|
||||||
}
|
}
|
||||||
Connect(IP, port);
|
LastConnectIP = IP;
|
||||||
|
LastConnectPort = port;
|
||||||
|
return Connect(IP, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Connect(string IP, int port)
|
bool Connect(string IP, int port)
|
||||||
{
|
{
|
||||||
//带回调的
|
//带回调的
|
||||||
try
|
try
|
||||||
@ -168,10 +170,13 @@ namespace HaoYueNet.ClientNetworkNet4x
|
|||||||
public void SendToServer(int CMDID, byte[] data)
|
public void SendToServer(int CMDID, byte[] data)
|
||||||
{
|
{
|
||||||
//LogOut("准备数据 CMDID=> "+CMDID);
|
//LogOut("准备数据 CMDID=> "+CMDID);
|
||||||
|
/*
|
||||||
HunterNet_C2S _c2sdata = new HunterNet_C2S();
|
HunterNet_C2S _c2sdata = new HunterNet_C2S();
|
||||||
_c2sdata.HunterNetCoreCmdID = CMDID;
|
_c2sdata.HunterNetCoreCmdID = CMDID;
|
||||||
_c2sdata.HunterNetCoreData = ByteString.CopyFrom(data);
|
_c2sdata.HunterNetCoreData = ByteString.CopyFrom(data);
|
||||||
byte[] _finaldata = Serizlize(_c2sdata);
|
byte[] _finaldata = Serizlize(_c2sdata);
|
||||||
|
*/
|
||||||
|
byte[] _finaldata = HunterNet_C2S.CreatePkgData((ushort)CMDID, data);
|
||||||
SendToSocket(_finaldata);
|
SendToSocket(_finaldata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,9 +249,14 @@ namespace HaoYueNet.ClientNetworkNet4x
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
HunterNet_S2C _c2s = DeSerizlize<HunterNet_S2C>(data);
|
HunterNet_S2C _c2s = DeSerizlize<HunterNet_S2C>(data);
|
||||||
|
|
||||||
OnReceiveData(_c2s.HunterNetCoreCmdID, _c2s.HunterNetCoreERRORCode, _c2s.HunterNetCoreData.ToArray());
|
OnReceiveData(_c2s.HunterNetCoreCmdID, _c2s.HunterNetCoreERRORCode, _c2s.HunterNetCoreData.ToArray());
|
||||||
|
*/
|
||||||
|
|
||||||
|
HunterNet_S2C.AnalysisPkgData(data, out ushort CmdID, out ushort Error, out byte[] resultdata);
|
||||||
|
OnReceiveData(CmdID, Error, resultdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -352,18 +362,6 @@ namespace HaoYueNet.ClientNetworkNet4x
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] Serizlize(IMessage msg)
|
|
||||||
{
|
|
||||||
return msg.ToByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T DeSerizlize<T>(byte[] bytes)
|
|
||||||
{
|
|
||||||
var msgType = typeof(T);
|
|
||||||
object msg = Activator.CreateInstance(msgType);
|
|
||||||
((IMessage)msg).MergeFrom(bytes);
|
|
||||||
return (T)msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LogOut(string Msg)
|
public void LogOut(string Msg)
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
using Google.Protobuf;
|
using System;
|
||||||
using HunterProtobufCore;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using static HaoYueNet.ClientNetworkNet4x.BaseData;
|
||||||
|
|
||||||
namespace HaoYueNet.ClientNetworkNet4x
|
namespace HaoYueNet.ClientNetworkNet4x
|
||||||
{
|
{
|
||||||
|
namespace HaoYueNet.ClientNetwork
|
||||||
|
{
|
||||||
public class NetworkHelperP2PCore
|
public class NetworkHelperP2PCore
|
||||||
{
|
{
|
||||||
private Socket client;
|
private Socket client;
|
||||||
@ -169,11 +169,13 @@ namespace HaoYueNet.ClientNetworkNet4x
|
|||||||
public void SendToSocket(int CMDID, int ERRCODE, byte[] data)
|
public void SendToSocket(int CMDID, int ERRCODE, byte[] data)
|
||||||
{
|
{
|
||||||
//LogOut("准备数据 CMDID=> "+CMDID);
|
//LogOut("准备数据 CMDID=> "+CMDID);
|
||||||
HunterNet_S2C _s2sdata = new HunterNet_S2C();
|
/*HunterNet_S2C _s2sdata = new HunterNet_S2C();
|
||||||
_s2sdata.HunterNetCoreCmdID = CMDID;
|
_s2sdata.HunterNetCoreCmdID = CMDID;
|
||||||
_s2sdata.HunterNetCoreERRORCode = ERRCODE;
|
_s2sdata.HunterNetCoreERRORCode = ERRCODE;
|
||||||
_s2sdata.HunterNetCoreData = ByteString.CopyFrom(data);
|
_s2sdata.HunterNetCoreData = ByteString.CopyFrom(data);
|
||||||
byte[] _finaldata = Serizlize(_s2sdata);
|
byte[] _finaldata = Serizlize(_s2sdata);*/
|
||||||
|
|
||||||
|
byte[] _finaldata = HunterNet_S2C.CreatePkgData((ushort)CMDID, (ushort)ERRCODE, data);
|
||||||
SendToSocket(_finaldata);
|
SendToSocket(_finaldata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,9 +252,12 @@ namespace HaoYueNet.ClientNetworkNet4x
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
HunterNet_S2C _c2s = DeSerizlize<HunterNet_S2C>(data);
|
HunterNet_S2C _c2s = DeSerizlize<HunterNet_S2C>(data);
|
||||||
|
|
||||||
OnDataCallBack(_c2s.HunterNetCoreCmdID, _c2s.HunterNetCoreERRORCode, _c2s.HunterNetCoreData.ToArray());
|
OnDataCallBack(_c2s.HunterNetCoreCmdID, _c2s.HunterNetCoreERRORCode, _c2s.HunterNetCoreData.ToArray());
|
||||||
|
*/
|
||||||
|
HunterNet_S2C.AnalysisPkgData(data, out ushort CmdID, out ushort Error, out byte[] resultdata);
|
||||||
|
OnDataCallBack(CmdID, Error, resultdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryStream memoryStream = new MemoryStream();//开辟一个内存流
|
MemoryStream memoryStream = new MemoryStream();//开辟一个内存流
|
||||||
@ -358,19 +363,6 @@ namespace HaoYueNet.ClientNetworkNet4x
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] Serizlize(IMessage msg)
|
|
||||||
{
|
|
||||||
return msg.ToByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T DeSerizlize<T>(byte[] bytes)
|
|
||||||
{
|
|
||||||
var msgType = typeof(T);
|
|
||||||
object msg = Activator.CreateInstance(msgType);
|
|
||||||
((IMessage)msg).MergeFrom(bytes);
|
|
||||||
return (T)msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LogOut(string Msg)
|
public void LogOut(string Msg)
|
||||||
{
|
{
|
||||||
//Console.WriteLine(Msg);
|
//Console.WriteLine(Msg);
|
||||||
@ -382,4 +374,5 @@ namespace HaoYueNet.ClientNetworkNet4x
|
|||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,505 +0,0 @@
|
|||||||
// <auto-generated>
|
|
||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
// source: protobuf_HunterNetCore.proto
|
|
||||||
// </auto-generated>
|
|
||||||
#pragma warning disable 1591, 0612, 3021
|
|
||||||
#region Designer generated code
|
|
||||||
|
|
||||||
using pb = global::Google.Protobuf;
|
|
||||||
using pbr = global::Google.Protobuf.Reflection;
|
|
||||||
namespace HunterProtobufCore
|
|
||||||
{
|
|
||||||
|
|
||||||
/// <summary>Holder for reflection information generated from protobuf_HunterNetCore.proto</summary>
|
|
||||||
public static partial class ProtobufHunterNetCoreReflection {
|
|
||||||
|
|
||||||
#region Descriptor
|
|
||||||
/// <summary>File descriptor for protobuf_HunterNetCore.proto</summary>
|
|
||||||
public static pbr::FileDescriptor Descriptor {
|
|
||||||
get { return descriptor; }
|
|
||||||
}
|
|
||||||
private static pbr::FileDescriptor descriptor;
|
|
||||||
|
|
||||||
static ProtobufHunterNetCoreReflection() {
|
|
||||||
byte[] descriptorData = global::System.Convert.FromBase64String(
|
|
||||||
string.Concat(
|
|
||||||
"Chxwcm90b2J1Zl9IdW50ZXJOZXRDb3JlLnByb3RvEhJIdW50ZXJQcm90b2J1",
|
|
||||||
"ZkNvcmUiSAoNSHVudGVyTmV0X0MyUxIbChNIdW50ZXJOZXRDb3JlX0NtZElE",
|
|
||||||
"GAEgASgFEhoKEkh1bnRlck5ldENvcmVfRGF0YRgCIAEoDCJpCg1IdW50ZXJO",
|
|
||||||
"ZXRfUzJDEhsKE0h1bnRlck5ldENvcmVfQ21kSUQYASABKAUSHwoXSHVudGVy",
|
|
||||||
"TmV0Q29yZV9FUlJPUkNvZGUYAiABKAUSGgoSSHVudGVyTmV0Q29yZV9EYXRh",
|
|
||||||
"GAMgASgMQgJIAWIGcHJvdG8z"));
|
|
||||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
|
||||||
new pbr::FileDescriptor[] { },
|
|
||||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
|
||||||
new pbr::GeneratedClrTypeInfo(typeof(global::HunterProtobufCore.HunterNet_C2S), global::HunterProtobufCore.HunterNet_C2S.Parser, new[]{ "HunterNetCoreCmdID", "HunterNetCoreData" }, null, null, null, null),
|
|
||||||
new pbr::GeneratedClrTypeInfo(typeof(global::HunterProtobufCore.HunterNet_S2C), global::HunterProtobufCore.HunterNet_S2C.Parser, new[]{ "HunterNetCoreCmdID", "HunterNetCoreERRORCode", "HunterNetCoreData" }, null, null, null, null)
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
|
||||||
#region Messages
|
|
||||||
/// <summary>
|
|
||||||
///上行
|
|
||||||
/// </summary>
|
|
||||||
public sealed partial class HunterNet_C2S : pb::IMessage<HunterNet_C2S>
|
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
|
||||||
, pb::IBufferMessage
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
private static readonly pb::MessageParser<HunterNet_C2S> _parser = new pb::MessageParser<HunterNet_C2S>(() => new HunterNet_C2S());
|
|
||||||
private pb::UnknownFieldSet _unknownFields;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public static pb::MessageParser<HunterNet_C2S> Parser { get { return _parser; } }
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public static pbr::MessageDescriptor Descriptor {
|
|
||||||
get { return global::HunterProtobufCore.ProtobufHunterNetCoreReflection.Descriptor.MessageTypes[0]; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
|
||||||
get { return Descriptor; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_C2S() {
|
|
||||||
OnConstruction();
|
|
||||||
}
|
|
||||||
|
|
||||||
partial void OnConstruction();
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_C2S(HunterNet_C2S other) : this() {
|
|
||||||
hunterNetCoreCmdID_ = other.hunterNetCoreCmdID_;
|
|
||||||
hunterNetCoreData_ = other.hunterNetCoreData_;
|
|
||||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_C2S Clone() {
|
|
||||||
return new HunterNet_C2S(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_CmdID" field.</summary>
|
|
||||||
public const int HunterNetCoreCmdIDFieldNumber = 1;
|
|
||||||
private int hunterNetCoreCmdID_;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public int HunterNetCoreCmdID {
|
|
||||||
get { return hunterNetCoreCmdID_; }
|
|
||||||
set {
|
|
||||||
hunterNetCoreCmdID_ = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_Data" field.</summary>
|
|
||||||
public const int HunterNetCoreDataFieldNumber = 2;
|
|
||||||
private pb::ByteString hunterNetCoreData_ = pb::ByteString.Empty;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public pb::ByteString HunterNetCoreData {
|
|
||||||
get { return hunterNetCoreData_; }
|
|
||||||
set {
|
|
||||||
hunterNetCoreData_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public override bool Equals(object other) {
|
|
||||||
return Equals(other as HunterNet_C2S);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public bool Equals(HunterNet_C2S other) {
|
|
||||||
if (ReferenceEquals(other, null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (ReferenceEquals(other, this)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (HunterNetCoreCmdID != other.HunterNetCoreCmdID) return false;
|
|
||||||
if (HunterNetCoreData != other.HunterNetCoreData) return false;
|
|
||||||
return Equals(_unknownFields, other._unknownFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public override int GetHashCode() {
|
|
||||||
int hash = 1;
|
|
||||||
if (HunterNetCoreCmdID != 0) hash ^= HunterNetCoreCmdID.GetHashCode();
|
|
||||||
if (HunterNetCoreData.Length != 0) hash ^= HunterNetCoreData.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 (HunterNetCoreCmdID != 0) {
|
|
||||||
output.WriteRawTag(8);
|
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
output.WriteRawTag(18);
|
|
||||||
output.WriteBytes(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
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 (HunterNetCoreCmdID != 0) {
|
|
||||||
output.WriteRawTag(8);
|
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
output.WriteRawTag(18);
|
|
||||||
output.WriteBytes(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
if (_unknownFields != null) {
|
|
||||||
_unknownFields.WriteTo(ref output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public int CalculateSize() {
|
|
||||||
int size = 0;
|
|
||||||
if (HunterNetCoreCmdID != 0) {
|
|
||||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
size += 1 + pb::CodedOutputStream.ComputeBytesSize(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
if (_unknownFields != null) {
|
|
||||||
size += _unknownFields.CalculateSize();
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public void MergeFrom(HunterNet_C2S other) {
|
|
||||||
if (other == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (other.HunterNetCoreCmdID != 0) {
|
|
||||||
HunterNetCoreCmdID = other.HunterNetCoreCmdID;
|
|
||||||
}
|
|
||||||
if (other.HunterNetCoreData.Length != 0) {
|
|
||||||
HunterNetCoreData = other.HunterNetCoreData;
|
|
||||||
}
|
|
||||||
_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 8: {
|
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 18: {
|
|
||||||
HunterNetCoreData = input.ReadBytes();
|
|
||||||
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 8: {
|
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 18: {
|
|
||||||
HunterNetCoreData = input.ReadBytes();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///下行
|
|
||||||
/// </summary>
|
|
||||||
public sealed partial class HunterNet_S2C : pb::IMessage<HunterNet_S2C>
|
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
|
||||||
, pb::IBufferMessage
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
private static readonly pb::MessageParser<HunterNet_S2C> _parser = new pb::MessageParser<HunterNet_S2C>(() => new HunterNet_S2C());
|
|
||||||
private pb::UnknownFieldSet _unknownFields;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public static pb::MessageParser<HunterNet_S2C> Parser { get { return _parser; } }
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public static pbr::MessageDescriptor Descriptor {
|
|
||||||
get { return global::HunterProtobufCore.ProtobufHunterNetCoreReflection.Descriptor.MessageTypes[1]; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
|
||||||
get { return Descriptor; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_S2C() {
|
|
||||||
OnConstruction();
|
|
||||||
}
|
|
||||||
|
|
||||||
partial void OnConstruction();
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_S2C(HunterNet_S2C other) : this() {
|
|
||||||
hunterNetCoreCmdID_ = other.hunterNetCoreCmdID_;
|
|
||||||
hunterNetCoreERRORCode_ = other.hunterNetCoreERRORCode_;
|
|
||||||
hunterNetCoreData_ = other.hunterNetCoreData_;
|
|
||||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public HunterNet_S2C Clone() {
|
|
||||||
return new HunterNet_S2C(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_CmdID" field.</summary>
|
|
||||||
public const int HunterNetCoreCmdIDFieldNumber = 1;
|
|
||||||
private int hunterNetCoreCmdID_;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public int HunterNetCoreCmdID {
|
|
||||||
get { return hunterNetCoreCmdID_; }
|
|
||||||
set {
|
|
||||||
hunterNetCoreCmdID_ = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_ERRORCode" field.</summary>
|
|
||||||
public const int HunterNetCoreERRORCodeFieldNumber = 2;
|
|
||||||
private int hunterNetCoreERRORCode_;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public int HunterNetCoreERRORCode {
|
|
||||||
get { return hunterNetCoreERRORCode_; }
|
|
||||||
set {
|
|
||||||
hunterNetCoreERRORCode_ = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_Data" field.</summary>
|
|
||||||
public const int HunterNetCoreDataFieldNumber = 3;
|
|
||||||
private pb::ByteString hunterNetCoreData_ = pb::ByteString.Empty;
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public pb::ByteString HunterNetCoreData {
|
|
||||||
get { return hunterNetCoreData_; }
|
|
||||||
set {
|
|
||||||
hunterNetCoreData_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public override bool Equals(object other) {
|
|
||||||
return Equals(other as HunterNet_S2C);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public bool Equals(HunterNet_S2C other) {
|
|
||||||
if (ReferenceEquals(other, null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (ReferenceEquals(other, this)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (HunterNetCoreCmdID != other.HunterNetCoreCmdID) return false;
|
|
||||||
if (HunterNetCoreERRORCode != other.HunterNetCoreERRORCode) return false;
|
|
||||||
if (HunterNetCoreData != other.HunterNetCoreData) return false;
|
|
||||||
return Equals(_unknownFields, other._unknownFields);
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public override int GetHashCode() {
|
|
||||||
int hash = 1;
|
|
||||||
if (HunterNetCoreCmdID != 0) hash ^= HunterNetCoreCmdID.GetHashCode();
|
|
||||||
if (HunterNetCoreERRORCode != 0) hash ^= HunterNetCoreERRORCode.GetHashCode();
|
|
||||||
if (HunterNetCoreData.Length != 0) hash ^= HunterNetCoreData.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 (HunterNetCoreCmdID != 0) {
|
|
||||||
output.WriteRawTag(8);
|
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreERRORCode != 0) {
|
|
||||||
output.WriteRawTag(16);
|
|
||||||
output.WriteInt32(HunterNetCoreERRORCode);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
output.WriteRawTag(26);
|
|
||||||
output.WriteBytes(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
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 (HunterNetCoreCmdID != 0) {
|
|
||||||
output.WriteRawTag(8);
|
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreERRORCode != 0) {
|
|
||||||
output.WriteRawTag(16);
|
|
||||||
output.WriteInt32(HunterNetCoreERRORCode);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
output.WriteRawTag(26);
|
|
||||||
output.WriteBytes(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
if (_unknownFields != null) {
|
|
||||||
_unknownFields.WriteTo(ref output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public int CalculateSize() {
|
|
||||||
int size = 0;
|
|
||||||
if (HunterNetCoreCmdID != 0) {
|
|
||||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreCmdID);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreERRORCode != 0) {
|
|
||||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreERRORCode);
|
|
||||||
}
|
|
||||||
if (HunterNetCoreData.Length != 0) {
|
|
||||||
size += 1 + pb::CodedOutputStream.ComputeBytesSize(HunterNetCoreData);
|
|
||||||
}
|
|
||||||
if (_unknownFields != null) {
|
|
||||||
size += _unknownFields.CalculateSize();
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
|
||||||
public void MergeFrom(HunterNet_S2C other) {
|
|
||||||
if (other == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (other.HunterNetCoreCmdID != 0) {
|
|
||||||
HunterNetCoreCmdID = other.HunterNetCoreCmdID;
|
|
||||||
}
|
|
||||||
if (other.HunterNetCoreERRORCode != 0) {
|
|
||||||
HunterNetCoreERRORCode = other.HunterNetCoreERRORCode;
|
|
||||||
}
|
|
||||||
if (other.HunterNetCoreData.Length != 0) {
|
|
||||||
HunterNetCoreData = other.HunterNetCoreData;
|
|
||||||
}
|
|
||||||
_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 8: {
|
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 16: {
|
|
||||||
HunterNetCoreERRORCode = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 26: {
|
|
||||||
HunterNetCoreData = input.ReadBytes();
|
|
||||||
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 8: {
|
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 16: {
|
|
||||||
HunterNetCoreERRORCode = input.ReadInt32();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 26: {
|
|
||||||
HunterNetCoreData = input.ReadBytes();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Designer generated code
|
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
|
|
||||||
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
|
|
||||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
|
|
||||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
|
|
||||||
</packages>
|
|
49
NetLib/HaoYueNet.ServerNetwork/BaseData.cs
Normal file
49
NetLib/HaoYueNet.ServerNetwork/BaseData.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HaoYueNet.ServerNetwork
|
||||||
|
{
|
||||||
|
public static class BaseData
|
||||||
|
{
|
||||||
|
public static class HunterNet_S2C
|
||||||
|
{
|
||||||
|
public static byte[] CreatePkgData(UInt16 CmdID, UInt16 Error, byte[] data)
|
||||||
|
{
|
||||||
|
byte[] newdata = new byte[2 + 2 + data.Length];
|
||||||
|
BitConverter.GetBytes(CmdID).CopyTo(newdata, 0);
|
||||||
|
BitConverter.GetBytes(Error).CopyTo(newdata, 2);
|
||||||
|
Array.Copy(data, 0, newdata, 4, data.Length);
|
||||||
|
return newdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AnalysisPkgData(byte[] srcdata, out UInt16 CmdID, out UInt16 Error, out byte[] data)
|
||||||
|
{
|
||||||
|
data = new byte[srcdata.Length - 2 - 2];
|
||||||
|
CmdID = BitConverter.ToUInt16(srcdata, 0);
|
||||||
|
Error = BitConverter.ToUInt16(srcdata, 2);
|
||||||
|
Array.Copy(srcdata, 4, data, 0, data.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class HunterNet_C2S
|
||||||
|
{
|
||||||
|
public static byte[] CreatePkgData(UInt16 CmdID, byte[] data)
|
||||||
|
{
|
||||||
|
byte[] newdata = new byte[2 + data.Length];
|
||||||
|
BitConverter.GetBytes(CmdID).CopyTo(newdata, 0);
|
||||||
|
Array.Copy(data, 0, newdata, 2, data.Length);
|
||||||
|
return newdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AnalysisPkgData(byte[] srcdata, out UInt16 CmdID, out byte[] data)
|
||||||
|
{
|
||||||
|
data = new byte[srcdata.Length - 2];
|
||||||
|
CmdID = BitConverter.ToUInt16(srcdata, 0);
|
||||||
|
Array.Copy(srcdata, 2, data, 0, data.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,10 +6,4 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Google.Protobuf">
|
|
||||||
<HintPath>..\Google.Protobuf.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
using Google.Protobuf;
|
//using HunterProtobufCore;
|
||||||
using HunterProtobufCore;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using static HaoYueNet.ServerNetwork.BaseData;
|
||||||
|
|
||||||
namespace HaoYueNet.ServerNetwork
|
namespace HaoYueNet.ServerNetwork
|
||||||
{
|
{
|
||||||
@ -646,11 +645,12 @@ namespace HaoYueNet.ServerNetwork
|
|||||||
public void SendToSocket(Socket sk, int CMDID, int ERRCODE, byte[] data)
|
public void SendToSocket(Socket sk, int CMDID, int ERRCODE, byte[] data)
|
||||||
{
|
{
|
||||||
AsyncUserToken token = GetAsyncUserTokenForSocket(sk);
|
AsyncUserToken token = GetAsyncUserTokenForSocket(sk);
|
||||||
HunterNet_S2C _s2cdata = new HunterNet_S2C();
|
/*HunterNet_S2C _s2cdata = new HunterNet_S2C();
|
||||||
_s2cdata.HunterNetCoreCmdID = CMDID;
|
_s2cdata.HunterNetCoreCmdID = CMDID;
|
||||||
_s2cdata.HunterNetCoreData = ByteString.CopyFrom(data);
|
_s2cdata.HunterNetCoreData = ByteString.CopyFrom(data);
|
||||||
_s2cdata.HunterNetCoreERRORCode = ERRCODE;
|
_s2cdata.HunterNetCoreERRORCode = ERRCODE;
|
||||||
byte[] _finaldata = Serizlize(_s2cdata);
|
byte[] _finaldata = Serizlize(_s2cdata);*/
|
||||||
|
byte[] _finaldata = HunterNet_S2C.CreatePkgData((ushort)CMDID, (ushort)ERRCODE, data);
|
||||||
SendWithIndex(token, _finaldata);
|
SendWithIndex(token, _finaldata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,10 +668,14 @@ namespace HaoYueNet.ServerNetwork
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HunterNet_C2S _s2c = DeSerizlize<HunterNet_C2S>(data);
|
|
||||||
//将数据包交给后台处理,这里你也可以新开个线程来处理.加快速度.
|
//将数据包交给后台处理,这里你也可以新开个线程来处理.加快速度.
|
||||||
|
/*
|
||||||
|
HunterNet_C2S _s2c = DeSerizlize<HunterNet_C2S>(data);
|
||||||
OnReceive?.Invoke(sk, (int)_s2c.HunterNetCoreCmdID, _s2c.HunterNetCoreData.ToArray());
|
OnReceive?.Invoke(sk, (int)_s2c.HunterNetCoreCmdID, _s2c.HunterNetCoreData.ToArray());
|
||||||
//DataCallBack(sk, (int)_s2c.HunterNetCoreCmdID, _s2c.HunterNetCoreData.ToArray());
|
//DataCallBack(sk, (int)_s2c.HunterNetCoreCmdID, _s2c.HunterNetCoreData.ToArray());
|
||||||
|
*/
|
||||||
|
HunterNet_C2S.AnalysisPkgData(data, out ushort CmdID, out byte[] resultdata);
|
||||||
|
OnReceive?.Invoke(sk, CmdID, resultdata);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -738,17 +742,5 @@ namespace HaoYueNet.ServerNetwork
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static byte[] Serizlize(IMessage msg)
|
|
||||||
{
|
|
||||||
return msg.ToByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T DeSerizlize<T>(byte[] bytes)
|
|
||||||
{
|
|
||||||
var msgType = typeof(T);
|
|
||||||
object msg = Activator.CreateInstance(msgType);
|
|
||||||
((IMessage)msg).MergeFrom(bytes);
|
|
||||||
return (T)msg;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,506 +1,506 @@
|
|||||||
// <auto-generated>
|
//// <auto-generated>
|
||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
//// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
// source: protobuf_HunterNetCore.proto
|
//// source: protobuf_HunterNetCore.proto
|
||||||
// </auto-generated>
|
//// </auto-generated>
|
||||||
#pragma warning disable 1591, 0612, 3021
|
//#pragma warning disable 1591, 0612, 3021
|
||||||
#region Designer generated code
|
//#region Designer generated code
|
||||||
|
|
||||||
using pb = global::Google.Protobuf;
|
//using pb = global::Google.Protobuf;
|
||||||
using pbc = global::Google.Protobuf.Collections;
|
//using pbc = global::Google.Protobuf.Collections;
|
||||||
using pbr = global::Google.Protobuf.Reflection;
|
//using pbr = global::Google.Protobuf.Reflection;
|
||||||
using scg = global::System.Collections.Generic;
|
//using scg = global::System.Collections.Generic;
|
||||||
namespace HunterProtobufCore {
|
//namespace HunterProtobufCore {
|
||||||
|
|
||||||
/// <summary>Holder for reflection information generated from protobuf_HunterNetCore.proto</summary>
|
// /// <summary>Holder for reflection information generated from protobuf_HunterNetCore.proto</summary>
|
||||||
public static partial class ProtobufHunterNetCoreReflection {
|
// public static partial class ProtobufHunterNetCoreReflection {
|
||||||
|
|
||||||
#region Descriptor
|
// #region Descriptor
|
||||||
/// <summary>File descriptor for protobuf_HunterNetCore.proto</summary>
|
// /// <summary>File descriptor for protobuf_HunterNetCore.proto</summary>
|
||||||
public static pbr::FileDescriptor Descriptor {
|
// public static pbr::FileDescriptor Descriptor {
|
||||||
get { return descriptor; }
|
// get { return descriptor; }
|
||||||
}
|
// }
|
||||||
private static pbr::FileDescriptor descriptor;
|
// private static pbr::FileDescriptor descriptor;
|
||||||
|
|
||||||
static ProtobufHunterNetCoreReflection() {
|
// static ProtobufHunterNetCoreReflection() {
|
||||||
byte[] descriptorData = global::System.Convert.FromBase64String(
|
// byte[] descriptorData = global::System.Convert.FromBase64String(
|
||||||
string.Concat(
|
// string.Concat(
|
||||||
"Chxwcm90b2J1Zl9IdW50ZXJOZXRDb3JlLnByb3RvEhJIdW50ZXJQcm90b2J1",
|
// "Chxwcm90b2J1Zl9IdW50ZXJOZXRDb3JlLnByb3RvEhJIdW50ZXJQcm90b2J1",
|
||||||
"ZkNvcmUiSAoNSHVudGVyTmV0X0MyUxIbChNIdW50ZXJOZXRDb3JlX0NtZElE",
|
// "ZkNvcmUiSAoNSHVudGVyTmV0X0MyUxIbChNIdW50ZXJOZXRDb3JlX0NtZElE",
|
||||||
"GAEgASgFEhoKEkh1bnRlck5ldENvcmVfRGF0YRgCIAEoDCJpCg1IdW50ZXJO",
|
// "GAEgASgFEhoKEkh1bnRlck5ldENvcmVfRGF0YRgCIAEoDCJpCg1IdW50ZXJO",
|
||||||
"ZXRfUzJDEhsKE0h1bnRlck5ldENvcmVfQ21kSUQYASABKAUSHwoXSHVudGVy",
|
// "ZXRfUzJDEhsKE0h1bnRlck5ldENvcmVfQ21kSUQYASABKAUSHwoXSHVudGVy",
|
||||||
"TmV0Q29yZV9FUlJPUkNvZGUYAiABKAUSGgoSSHVudGVyTmV0Q29yZV9EYXRh",
|
// "TmV0Q29yZV9FUlJPUkNvZGUYAiABKAUSGgoSSHVudGVyTmV0Q29yZV9EYXRh",
|
||||||
"GAMgASgMQgJIAWIGcHJvdG8z"));
|
// "GAMgASgMQgJIAWIGcHJvdG8z"));
|
||||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
// descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||||
new pbr::FileDescriptor[] { },
|
// new pbr::FileDescriptor[] { },
|
||||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
// new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||||
new pbr::GeneratedClrTypeInfo(typeof(global::HunterProtobufCore.HunterNet_C2S), global::HunterProtobufCore.HunterNet_C2S.Parser, new[]{ "HunterNetCoreCmdID", "HunterNetCoreData" }, null, null, null, null),
|
// new pbr::GeneratedClrTypeInfo(typeof(global::HunterProtobufCore.HunterNet_C2S), global::HunterProtobufCore.HunterNet_C2S.Parser, new[]{ "HunterNetCoreCmdID", "HunterNetCoreData" }, null, null, null, null),
|
||||||
new pbr::GeneratedClrTypeInfo(typeof(global::HunterProtobufCore.HunterNet_S2C), global::HunterProtobufCore.HunterNet_S2C.Parser, new[]{ "HunterNetCoreCmdID", "HunterNetCoreERRORCode", "HunterNetCoreData" }, null, null, null, null)
|
// new pbr::GeneratedClrTypeInfo(typeof(global::HunterProtobufCore.HunterNet_S2C), global::HunterProtobufCore.HunterNet_S2C.Parser, new[]{ "HunterNetCoreCmdID", "HunterNetCoreERRORCode", "HunterNetCoreData" }, null, null, null, null)
|
||||||
}));
|
// }));
|
||||||
}
|
// }
|
||||||
#endregion
|
// #endregion
|
||||||
|
|
||||||
}
|
// }
|
||||||
#region Messages
|
// #region Messages
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
///上行
|
// ///上行
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public sealed partial class HunterNet_C2S : pb::IMessage<HunterNet_C2S>
|
// public sealed partial class HunterNet_C2S : pb::IMessage<HunterNet_C2S>
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
// #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||||
, pb::IBufferMessage
|
// , pb::IBufferMessage
|
||||||
#endif
|
// #endif
|
||||||
{
|
// {
|
||||||
private static readonly pb::MessageParser<HunterNet_C2S> _parser = new pb::MessageParser<HunterNet_C2S>(() => new HunterNet_C2S());
|
// private static readonly pb::MessageParser<HunterNet_C2S> _parser = new pb::MessageParser<HunterNet_C2S>(() => new HunterNet_C2S());
|
||||||
private pb::UnknownFieldSet _unknownFields;
|
// private pb::UnknownFieldSet _unknownFields;
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public static pb::MessageParser<HunterNet_C2S> Parser { get { return _parser; } }
|
// public static pb::MessageParser<HunterNet_C2S> Parser { get { return _parser; } }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public static pbr::MessageDescriptor Descriptor {
|
// public static pbr::MessageDescriptor Descriptor {
|
||||||
get { return global::HunterProtobufCore.ProtobufHunterNetCoreReflection.Descriptor.MessageTypes[0]; }
|
// get { return global::HunterProtobufCore.ProtobufHunterNetCoreReflection.Descriptor.MessageTypes[0]; }
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
// pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||||
get { return Descriptor; }
|
// get { return Descriptor; }
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public HunterNet_C2S() {
|
// public HunterNet_C2S() {
|
||||||
OnConstruction();
|
// OnConstruction();
|
||||||
}
|
// }
|
||||||
|
|
||||||
partial void OnConstruction();
|
// partial void OnConstruction();
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public HunterNet_C2S(HunterNet_C2S other) : this() {
|
// public HunterNet_C2S(HunterNet_C2S other) : this() {
|
||||||
hunterNetCoreCmdID_ = other.hunterNetCoreCmdID_;
|
// hunterNetCoreCmdID_ = other.hunterNetCoreCmdID_;
|
||||||
hunterNetCoreData_ = other.hunterNetCoreData_;
|
// hunterNetCoreData_ = other.hunterNetCoreData_;
|
||||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
// _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public HunterNet_C2S Clone() {
|
// public HunterNet_C2S Clone() {
|
||||||
return new HunterNet_C2S(this);
|
// return new HunterNet_C2S(this);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_CmdID" field.</summary>
|
// /// <summary>Field number for the "HunterNetCore_CmdID" field.</summary>
|
||||||
public const int HunterNetCoreCmdIDFieldNumber = 1;
|
// public const int HunterNetCoreCmdIDFieldNumber = 1;
|
||||||
private int hunterNetCoreCmdID_;
|
// private int hunterNetCoreCmdID_;
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public int HunterNetCoreCmdID {
|
// public int HunterNetCoreCmdID {
|
||||||
get { return hunterNetCoreCmdID_; }
|
// get { return hunterNetCoreCmdID_; }
|
||||||
set {
|
// set {
|
||||||
hunterNetCoreCmdID_ = value;
|
// hunterNetCoreCmdID_ = value;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_Data" field.</summary>
|
// /// <summary>Field number for the "HunterNetCore_Data" field.</summary>
|
||||||
public const int HunterNetCoreDataFieldNumber = 2;
|
// public const int HunterNetCoreDataFieldNumber = 2;
|
||||||
private pb::ByteString hunterNetCoreData_ = pb::ByteString.Empty;
|
// private pb::ByteString hunterNetCoreData_ = pb::ByteString.Empty;
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public pb::ByteString HunterNetCoreData {
|
// public pb::ByteString HunterNetCoreData {
|
||||||
get { return hunterNetCoreData_; }
|
// get { return hunterNetCoreData_; }
|
||||||
set {
|
// set {
|
||||||
hunterNetCoreData_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
// hunterNetCoreData_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public override bool Equals(object other) {
|
// public override bool Equals(object other) {
|
||||||
return Equals(other as HunterNet_C2S);
|
// return Equals(other as HunterNet_C2S);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public bool Equals(HunterNet_C2S other) {
|
// public bool Equals(HunterNet_C2S other) {
|
||||||
if (ReferenceEquals(other, null)) {
|
// if (ReferenceEquals(other, null)) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
if (ReferenceEquals(other, this)) {
|
// if (ReferenceEquals(other, this)) {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreCmdID != other.HunterNetCoreCmdID) return false;
|
// if (HunterNetCoreCmdID != other.HunterNetCoreCmdID) return false;
|
||||||
if (HunterNetCoreData != other.HunterNetCoreData) return false;
|
// if (HunterNetCoreData != other.HunterNetCoreData) return false;
|
||||||
return Equals(_unknownFields, other._unknownFields);
|
// return Equals(_unknownFields, other._unknownFields);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public override int GetHashCode() {
|
// public override int GetHashCode() {
|
||||||
int hash = 1;
|
// int hash = 1;
|
||||||
if (HunterNetCoreCmdID != 0) hash ^= HunterNetCoreCmdID.GetHashCode();
|
// if (HunterNetCoreCmdID != 0) hash ^= HunterNetCoreCmdID.GetHashCode();
|
||||||
if (HunterNetCoreData.Length != 0) hash ^= HunterNetCoreData.GetHashCode();
|
// if (HunterNetCoreData.Length != 0) hash ^= HunterNetCoreData.GetHashCode();
|
||||||
if (_unknownFields != null) {
|
// if (_unknownFields != null) {
|
||||||
hash ^= _unknownFields.GetHashCode();
|
// hash ^= _unknownFields.GetHashCode();
|
||||||
}
|
// }
|
||||||
return hash;
|
// return hash;
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public override string ToString() {
|
// public override string ToString() {
|
||||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
// return pb::JsonFormatter.ToDiagnosticString(this);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public void WriteTo(pb::CodedOutputStream output) {
|
// public void WriteTo(pb::CodedOutputStream output) {
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
// #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||||
output.WriteRawMessage(this);
|
// output.WriteRawMessage(this);
|
||||||
#else
|
// #else
|
||||||
if (HunterNetCoreCmdID != 0) {
|
// if (HunterNetCoreCmdID != 0) {
|
||||||
output.WriteRawTag(8);
|
// output.WriteRawTag(8);
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
// output.WriteInt32(HunterNetCoreCmdID);
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreData.Length != 0) {
|
// if (HunterNetCoreData.Length != 0) {
|
||||||
output.WriteRawTag(18);
|
// output.WriteRawTag(18);
|
||||||
output.WriteBytes(HunterNetCoreData);
|
// output.WriteBytes(HunterNetCoreData);
|
||||||
}
|
// }
|
||||||
if (_unknownFields != null) {
|
// if (_unknownFields != null) {
|
||||||
_unknownFields.WriteTo(output);
|
// _unknownFields.WriteTo(output);
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
// #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
// void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
||||||
if (HunterNetCoreCmdID != 0) {
|
// if (HunterNetCoreCmdID != 0) {
|
||||||
output.WriteRawTag(8);
|
// output.WriteRawTag(8);
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
// output.WriteInt32(HunterNetCoreCmdID);
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreData.Length != 0) {
|
// if (HunterNetCoreData.Length != 0) {
|
||||||
output.WriteRawTag(18);
|
// output.WriteRawTag(18);
|
||||||
output.WriteBytes(HunterNetCoreData);
|
// output.WriteBytes(HunterNetCoreData);
|
||||||
}
|
// }
|
||||||
if (_unknownFields != null) {
|
// if (_unknownFields != null) {
|
||||||
_unknownFields.WriteTo(ref output);
|
// _unknownFields.WriteTo(ref output);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public int CalculateSize() {
|
// public int CalculateSize() {
|
||||||
int size = 0;
|
// int size = 0;
|
||||||
if (HunterNetCoreCmdID != 0) {
|
// if (HunterNetCoreCmdID != 0) {
|
||||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreCmdID);
|
// size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreCmdID);
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreData.Length != 0) {
|
// if (HunterNetCoreData.Length != 0) {
|
||||||
size += 1 + pb::CodedOutputStream.ComputeBytesSize(HunterNetCoreData);
|
// size += 1 + pb::CodedOutputStream.ComputeBytesSize(HunterNetCoreData);
|
||||||
}
|
// }
|
||||||
if (_unknownFields != null) {
|
// if (_unknownFields != null) {
|
||||||
size += _unknownFields.CalculateSize();
|
// size += _unknownFields.CalculateSize();
|
||||||
}
|
// }
|
||||||
return size;
|
// return size;
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public void MergeFrom(HunterNet_C2S other) {
|
// public void MergeFrom(HunterNet_C2S other) {
|
||||||
if (other == null) {
|
// if (other == null) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (other.HunterNetCoreCmdID != 0) {
|
// if (other.HunterNetCoreCmdID != 0) {
|
||||||
HunterNetCoreCmdID = other.HunterNetCoreCmdID;
|
// HunterNetCoreCmdID = other.HunterNetCoreCmdID;
|
||||||
}
|
// }
|
||||||
if (other.HunterNetCoreData.Length != 0) {
|
// if (other.HunterNetCoreData.Length != 0) {
|
||||||
HunterNetCoreData = other.HunterNetCoreData;
|
// HunterNetCoreData = other.HunterNetCoreData;
|
||||||
}
|
// }
|
||||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
// _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public void MergeFrom(pb::CodedInputStream input) {
|
// public void MergeFrom(pb::CodedInputStream input) {
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
// #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||||
input.ReadRawMessage(this);
|
// input.ReadRawMessage(this);
|
||||||
#else
|
// #else
|
||||||
uint tag;
|
// uint tag;
|
||||||
while ((tag = input.ReadTag()) != 0) {
|
// while ((tag = input.ReadTag()) != 0) {
|
||||||
switch(tag) {
|
// switch(tag) {
|
||||||
default:
|
// default:
|
||||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
// _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
||||||
break;
|
// break;
|
||||||
case 8: {
|
// case 8: {
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
// HunterNetCoreCmdID = input.ReadInt32();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 18: {
|
// case 18: {
|
||||||
HunterNetCoreData = input.ReadBytes();
|
// HunterNetCoreData = input.ReadBytes();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
// #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
// void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
||||||
uint tag;
|
// uint tag;
|
||||||
while ((tag = input.ReadTag()) != 0) {
|
// while ((tag = input.ReadTag()) != 0) {
|
||||||
switch(tag) {
|
// switch(tag) {
|
||||||
default:
|
// default:
|
||||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
// _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
||||||
break;
|
// break;
|
||||||
case 8: {
|
// case 8: {
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
// HunterNetCoreCmdID = input.ReadInt32();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 18: {
|
// case 18: {
|
||||||
HunterNetCoreData = input.ReadBytes();
|
// HunterNetCoreData = input.ReadBytes();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
///下行
|
// ///下行
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
public sealed partial class HunterNet_S2C : pb::IMessage<HunterNet_S2C>
|
// public sealed partial class HunterNet_S2C : pb::IMessage<HunterNet_S2C>
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
// #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||||
, pb::IBufferMessage
|
// , pb::IBufferMessage
|
||||||
#endif
|
// #endif
|
||||||
{
|
// {
|
||||||
private static readonly pb::MessageParser<HunterNet_S2C> _parser = new pb::MessageParser<HunterNet_S2C>(() => new HunterNet_S2C());
|
// private static readonly pb::MessageParser<HunterNet_S2C> _parser = new pb::MessageParser<HunterNet_S2C>(() => new HunterNet_S2C());
|
||||||
private pb::UnknownFieldSet _unknownFields;
|
// private pb::UnknownFieldSet _unknownFields;
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public static pb::MessageParser<HunterNet_S2C> Parser { get { return _parser; } }
|
// public static pb::MessageParser<HunterNet_S2C> Parser { get { return _parser; } }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public static pbr::MessageDescriptor Descriptor {
|
// public static pbr::MessageDescriptor Descriptor {
|
||||||
get { return global::HunterProtobufCore.ProtobufHunterNetCoreReflection.Descriptor.MessageTypes[1]; }
|
// get { return global::HunterProtobufCore.ProtobufHunterNetCoreReflection.Descriptor.MessageTypes[1]; }
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
// pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||||
get { return Descriptor; }
|
// get { return Descriptor; }
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public HunterNet_S2C() {
|
// public HunterNet_S2C() {
|
||||||
OnConstruction();
|
// OnConstruction();
|
||||||
}
|
// }
|
||||||
|
|
||||||
partial void OnConstruction();
|
// partial void OnConstruction();
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public HunterNet_S2C(HunterNet_S2C other) : this() {
|
// public HunterNet_S2C(HunterNet_S2C other) : this() {
|
||||||
hunterNetCoreCmdID_ = other.hunterNetCoreCmdID_;
|
// hunterNetCoreCmdID_ = other.hunterNetCoreCmdID_;
|
||||||
hunterNetCoreERRORCode_ = other.hunterNetCoreERRORCode_;
|
// hunterNetCoreERRORCode_ = other.hunterNetCoreERRORCode_;
|
||||||
hunterNetCoreData_ = other.hunterNetCoreData_;
|
// hunterNetCoreData_ = other.hunterNetCoreData_;
|
||||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
// _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public HunterNet_S2C Clone() {
|
// public HunterNet_S2C Clone() {
|
||||||
return new HunterNet_S2C(this);
|
// return new HunterNet_S2C(this);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_CmdID" field.</summary>
|
// /// <summary>Field number for the "HunterNetCore_CmdID" field.</summary>
|
||||||
public const int HunterNetCoreCmdIDFieldNumber = 1;
|
// public const int HunterNetCoreCmdIDFieldNumber = 1;
|
||||||
private int hunterNetCoreCmdID_;
|
// private int hunterNetCoreCmdID_;
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public int HunterNetCoreCmdID {
|
// public int HunterNetCoreCmdID {
|
||||||
get { return hunterNetCoreCmdID_; }
|
// get { return hunterNetCoreCmdID_; }
|
||||||
set {
|
// set {
|
||||||
hunterNetCoreCmdID_ = value;
|
// hunterNetCoreCmdID_ = value;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_ERRORCode" field.</summary>
|
// /// <summary>Field number for the "HunterNetCore_ERRORCode" field.</summary>
|
||||||
public const int HunterNetCoreERRORCodeFieldNumber = 2;
|
// public const int HunterNetCoreERRORCodeFieldNumber = 2;
|
||||||
private int hunterNetCoreERRORCode_;
|
// private int hunterNetCoreERRORCode_;
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public int HunterNetCoreERRORCode {
|
// public int HunterNetCoreERRORCode {
|
||||||
get { return hunterNetCoreERRORCode_; }
|
// get { return hunterNetCoreERRORCode_; }
|
||||||
set {
|
// set {
|
||||||
hunterNetCoreERRORCode_ = value;
|
// hunterNetCoreERRORCode_ = value;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary>Field number for the "HunterNetCore_Data" field.</summary>
|
// /// <summary>Field number for the "HunterNetCore_Data" field.</summary>
|
||||||
public const int HunterNetCoreDataFieldNumber = 3;
|
// public const int HunterNetCoreDataFieldNumber = 3;
|
||||||
private pb::ByteString hunterNetCoreData_ = pb::ByteString.Empty;
|
// private pb::ByteString hunterNetCoreData_ = pb::ByteString.Empty;
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public pb::ByteString HunterNetCoreData {
|
// public pb::ByteString HunterNetCoreData {
|
||||||
get { return hunterNetCoreData_; }
|
// get { return hunterNetCoreData_; }
|
||||||
set {
|
// set {
|
||||||
hunterNetCoreData_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
// hunterNetCoreData_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public override bool Equals(object other) {
|
// public override bool Equals(object other) {
|
||||||
return Equals(other as HunterNet_S2C);
|
// return Equals(other as HunterNet_S2C);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public bool Equals(HunterNet_S2C other) {
|
// public bool Equals(HunterNet_S2C other) {
|
||||||
if (ReferenceEquals(other, null)) {
|
// if (ReferenceEquals(other, null)) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
if (ReferenceEquals(other, this)) {
|
// if (ReferenceEquals(other, this)) {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreCmdID != other.HunterNetCoreCmdID) return false;
|
// if (HunterNetCoreCmdID != other.HunterNetCoreCmdID) return false;
|
||||||
if (HunterNetCoreERRORCode != other.HunterNetCoreERRORCode) return false;
|
// if (HunterNetCoreERRORCode != other.HunterNetCoreERRORCode) return false;
|
||||||
if (HunterNetCoreData != other.HunterNetCoreData) return false;
|
// if (HunterNetCoreData != other.HunterNetCoreData) return false;
|
||||||
return Equals(_unknownFields, other._unknownFields);
|
// return Equals(_unknownFields, other._unknownFields);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public override int GetHashCode() {
|
// public override int GetHashCode() {
|
||||||
int hash = 1;
|
// int hash = 1;
|
||||||
if (HunterNetCoreCmdID != 0) hash ^= HunterNetCoreCmdID.GetHashCode();
|
// if (HunterNetCoreCmdID != 0) hash ^= HunterNetCoreCmdID.GetHashCode();
|
||||||
if (HunterNetCoreERRORCode != 0) hash ^= HunterNetCoreERRORCode.GetHashCode();
|
// if (HunterNetCoreERRORCode != 0) hash ^= HunterNetCoreERRORCode.GetHashCode();
|
||||||
if (HunterNetCoreData.Length != 0) hash ^= HunterNetCoreData.GetHashCode();
|
// if (HunterNetCoreData.Length != 0) hash ^= HunterNetCoreData.GetHashCode();
|
||||||
if (_unknownFields != null) {
|
// if (_unknownFields != null) {
|
||||||
hash ^= _unknownFields.GetHashCode();
|
// hash ^= _unknownFields.GetHashCode();
|
||||||
}
|
// }
|
||||||
return hash;
|
// return hash;
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public override string ToString() {
|
// public override string ToString() {
|
||||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
// return pb::JsonFormatter.ToDiagnosticString(this);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public void WriteTo(pb::CodedOutputStream output) {
|
// public void WriteTo(pb::CodedOutputStream output) {
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
// #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||||
output.WriteRawMessage(this);
|
// output.WriteRawMessage(this);
|
||||||
#else
|
// #else
|
||||||
if (HunterNetCoreCmdID != 0) {
|
// if (HunterNetCoreCmdID != 0) {
|
||||||
output.WriteRawTag(8);
|
// output.WriteRawTag(8);
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
// output.WriteInt32(HunterNetCoreCmdID);
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreERRORCode != 0) {
|
// if (HunterNetCoreERRORCode != 0) {
|
||||||
output.WriteRawTag(16);
|
// output.WriteRawTag(16);
|
||||||
output.WriteInt32(HunterNetCoreERRORCode);
|
// output.WriteInt32(HunterNetCoreERRORCode);
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreData.Length != 0) {
|
// if (HunterNetCoreData.Length != 0) {
|
||||||
output.WriteRawTag(26);
|
// output.WriteRawTag(26);
|
||||||
output.WriteBytes(HunterNetCoreData);
|
// output.WriteBytes(HunterNetCoreData);
|
||||||
}
|
// }
|
||||||
if (_unknownFields != null) {
|
// if (_unknownFields != null) {
|
||||||
_unknownFields.WriteTo(output);
|
// _unknownFields.WriteTo(output);
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
// #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
// void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
||||||
if (HunterNetCoreCmdID != 0) {
|
// if (HunterNetCoreCmdID != 0) {
|
||||||
output.WriteRawTag(8);
|
// output.WriteRawTag(8);
|
||||||
output.WriteInt32(HunterNetCoreCmdID);
|
// output.WriteInt32(HunterNetCoreCmdID);
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreERRORCode != 0) {
|
// if (HunterNetCoreERRORCode != 0) {
|
||||||
output.WriteRawTag(16);
|
// output.WriteRawTag(16);
|
||||||
output.WriteInt32(HunterNetCoreERRORCode);
|
// output.WriteInt32(HunterNetCoreERRORCode);
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreData.Length != 0) {
|
// if (HunterNetCoreData.Length != 0) {
|
||||||
output.WriteRawTag(26);
|
// output.WriteRawTag(26);
|
||||||
output.WriteBytes(HunterNetCoreData);
|
// output.WriteBytes(HunterNetCoreData);
|
||||||
}
|
// }
|
||||||
if (_unknownFields != null) {
|
// if (_unknownFields != null) {
|
||||||
_unknownFields.WriteTo(ref output);
|
// _unknownFields.WriteTo(ref output);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public int CalculateSize() {
|
// public int CalculateSize() {
|
||||||
int size = 0;
|
// int size = 0;
|
||||||
if (HunterNetCoreCmdID != 0) {
|
// if (HunterNetCoreCmdID != 0) {
|
||||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreCmdID);
|
// size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreCmdID);
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreERRORCode != 0) {
|
// if (HunterNetCoreERRORCode != 0) {
|
||||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreERRORCode);
|
// size += 1 + pb::CodedOutputStream.ComputeInt32Size(HunterNetCoreERRORCode);
|
||||||
}
|
// }
|
||||||
if (HunterNetCoreData.Length != 0) {
|
// if (HunterNetCoreData.Length != 0) {
|
||||||
size += 1 + pb::CodedOutputStream.ComputeBytesSize(HunterNetCoreData);
|
// size += 1 + pb::CodedOutputStream.ComputeBytesSize(HunterNetCoreData);
|
||||||
}
|
// }
|
||||||
if (_unknownFields != null) {
|
// if (_unknownFields != null) {
|
||||||
size += _unknownFields.CalculateSize();
|
// size += _unknownFields.CalculateSize();
|
||||||
}
|
// }
|
||||||
return size;
|
// return size;
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public void MergeFrom(HunterNet_S2C other) {
|
// public void MergeFrom(HunterNet_S2C other) {
|
||||||
if (other == null) {
|
// if (other == null) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (other.HunterNetCoreCmdID != 0) {
|
// if (other.HunterNetCoreCmdID != 0) {
|
||||||
HunterNetCoreCmdID = other.HunterNetCoreCmdID;
|
// HunterNetCoreCmdID = other.HunterNetCoreCmdID;
|
||||||
}
|
// }
|
||||||
if (other.HunterNetCoreERRORCode != 0) {
|
// if (other.HunterNetCoreERRORCode != 0) {
|
||||||
HunterNetCoreERRORCode = other.HunterNetCoreERRORCode;
|
// HunterNetCoreERRORCode = other.HunterNetCoreERRORCode;
|
||||||
}
|
// }
|
||||||
if (other.HunterNetCoreData.Length != 0) {
|
// if (other.HunterNetCoreData.Length != 0) {
|
||||||
HunterNetCoreData = other.HunterNetCoreData;
|
// HunterNetCoreData = other.HunterNetCoreData;
|
||||||
}
|
// }
|
||||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
// _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||||
}
|
// }
|
||||||
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
public void MergeFrom(pb::CodedInputStream input) {
|
// public void MergeFrom(pb::CodedInputStream input) {
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
// #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||||
input.ReadRawMessage(this);
|
// input.ReadRawMessage(this);
|
||||||
#else
|
// #else
|
||||||
uint tag;
|
// uint tag;
|
||||||
while ((tag = input.ReadTag()) != 0) {
|
// while ((tag = input.ReadTag()) != 0) {
|
||||||
switch(tag) {
|
// switch(tag) {
|
||||||
default:
|
// default:
|
||||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
// _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
||||||
break;
|
// break;
|
||||||
case 8: {
|
// case 8: {
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
// HunterNetCoreCmdID = input.ReadInt32();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 16: {
|
// case 16: {
|
||||||
HunterNetCoreERRORCode = input.ReadInt32();
|
// HunterNetCoreERRORCode = input.ReadInt32();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 26: {
|
// case 26: {
|
||||||
HunterNetCoreData = input.ReadBytes();
|
// HunterNetCoreData = input.ReadBytes();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
// #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
// [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
// void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
||||||
uint tag;
|
// uint tag;
|
||||||
while ((tag = input.ReadTag()) != 0) {
|
// while ((tag = input.ReadTag()) != 0) {
|
||||||
switch(tag) {
|
// switch(tag) {
|
||||||
default:
|
// default:
|
||||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
// _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
||||||
break;
|
// break;
|
||||||
case 8: {
|
// case 8: {
|
||||||
HunterNetCoreCmdID = input.ReadInt32();
|
// HunterNetCoreCmdID = input.ReadInt32();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 16: {
|
// case 16: {
|
||||||
HunterNetCoreERRORCode = input.ReadInt32();
|
// HunterNetCoreERRORCode = input.ReadInt32();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case 26: {
|
// case 26: {
|
||||||
HunterNetCoreData = input.ReadBytes();
|
// HunterNetCoreData = input.ReadBytes();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
#endregion
|
// #endregion
|
||||||
|
|
||||||
}
|
//}
|
||||||
|
|
||||||
#endregion Designer generated code
|
//#endregion Designer generated code
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
# HaoYueNet
|
# HaoYueNet
|
||||||
|
|
||||||
.Net 7 的,自建基于IOCP的TCP的高性能网络库
|
.Net 7 的,自建基于IOCP的TCP的高性能网络库
|
||||||
使用Protobuff作为基础协议
|
|
||||||
|
使用Protobuff作为基础协议(网络库本身不依赖Protobuff,仅上层示例依赖)
|
||||||
|
|
||||||
|
网络库本身无依赖,可以用于任何数据通讯
|
||||||
|
|
||||||
包含服务端和客户端双端库,可直接用于各类.Net程序或Unity程序,做TCP通讯底层库。
|
包含服务端和客户端双端库,可直接用于各类.Net程序或Unity程序,做TCP通讯底层库。
|
||||||
|
|
||||||
|
@ -4,12 +4,10 @@ namespace ClientCore.Common
|
|||||||
{
|
{
|
||||||
public static class ProtoBufHelper
|
public static class ProtoBufHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
public static byte[] Serizlize(IMessage msg)
|
public static byte[] Serizlize(IMessage msg)
|
||||||
{
|
{
|
||||||
return msg.ToByteArray();
|
return msg.ToByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T DeSerizlize<T>(byte[] bytes)
|
public static T DeSerizlize<T>(byte[] bytes)
|
||||||
{
|
{
|
||||||
var msgType = typeof(T);
|
var msgType = typeof(T);
|
||||||
|
@ -17,7 +17,7 @@ namespace ClientCore.Manager
|
|||||||
LoginType = 0,
|
LoginType = 0,
|
||||||
Account = Account,
|
Account = Account,
|
||||||
};
|
};
|
||||||
App.networkHelper.SendToServer((int)CommandID.CmdLogin, NetworkHelper.Serizlize(msg));
|
App.networkHelper.SendToServer((int)CommandID.CmdLogin, ProtoBufHelper.Serizlize(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RecvLoginMsg(byte[] reqData)
|
public void RecvLoginMsg(byte[] reqData)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AxibugProtobuf;
|
using AxibugProtobuf;
|
||||||
|
using Google.Protobuf;
|
||||||
using HaoYueNet.ClientNetwork;
|
using HaoYueNet.ClientNetwork;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
Loading…
Reference in New Issue
Block a user