提交demo

This commit is contained in:
PC-20230316NUNE\Administrator
2024-08-21 16:18:52 +08:00
parent 17cb342387
commit 5858bd2407
23 changed files with 4418 additions and 9411 deletions

View File

@@ -6,8 +6,10 @@
NActionDemo = 2, //Demo 消息
NActionDemo2 = 3, //Demo 消息
ClientConnect = 11, //客户端连接
ClientDisconnect = 12, //客户端断开
LocalClientConnect = 11, //客户端连接 (用于客户端通知)
LocalClientDisconnect = 12, //客户端断开 (用于客户端通知)
ServerClientConnect = 13, //服务器客户端连接 (用于服务端通知)
ServerClientDisconnect = 14, //服务器客户端断开 (用于服务端通知)
NSyncFrameStart = 100, //帧同步开始
NSyncFrameEnd = 101, //帧同步结束

View File

@@ -28,6 +28,9 @@ namespace Plugins.JNGame.Network
public async Task StartConnect()
{
var url = $"{await this.GetUrl()}";
this._socket = new WebSocket(new Uri(url));

View File

@@ -63,7 +63,7 @@ namespace JNGame.Network
private Task OnConnected(ITcpClient client, ConnectedEventArgs e)
{
Debug.Log($"[JNTCPClient] 服务器连接成功");
Dispatch(new JNetParam(_id++,(int)NActionEnum.ClientConnect));
Dispatch(new JNetParam(_id++,(int)NActionEnum.LocalClientConnect));
return Task.CompletedTask;
}
@@ -77,7 +77,7 @@ namespace JNGame.Network
private Task OnDisconnected(ITcpClientBase client, DisconnectEventArgs e)
{
Debug.Log($"[JNTCPClient] 服务器断开");
Dispatch(new JNetParam(_id++,(int)NActionEnum.ClientDisconnect));
Dispatch(new JNetParam(_id++,(int)NActionEnum.LocalClientDisconnect));
return Task.CompletedTask;
}

View File

@@ -62,7 +62,7 @@ namespace JNGame.Network
private Task OnConnected(SocketClient client, ConnectedEventArgs e)
{
Debug.Log($"[JNTCPServer] 有客户端连接成功");
Dispatch((int)NActionEnum.ClientConnect,new JNServerParam()
Dispatch((int)NActionEnum.LocalClientConnect,new JNServerParam()
{
Client = client.Id
});
@@ -79,7 +79,7 @@ namespace JNGame.Network
private Task OnDisconnected(SocketClient client, DisconnectEventArgs e)
{
Debug.Log($"[JNTCPServer] 有客户端断开连接");
Dispatch((int)NActionEnum.ClientDisconnect,new JNServerParam()
Dispatch((int)NActionEnum.LocalClientDisconnect,new JNServerParam()
{
Client = client.Id
});

View File

@@ -22,30 +22,34 @@ public static partial class JNSyncMessageReflection {
static JNSyncMessageReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"ChNKTlN5bmNNZXNzYWdlLnByb3RvIksKDEpORnJhbWVJbnB1dBILCgNuSWQY",
"ASABKAUSEgoFaW5wdXQYAiABKAxIAIgBARIQCghjbGllbnRJZBgDIAEoBUII",
"CgZfaW5wdXQiLgoNSk5GcmFtZUlucHV0cxIdCgZpbnB1dHMYASADKAsyDS5K",
"TkZyYW1lSW5wdXQiPQoLSk5GcmFtZUluZm8SDQoFaW5kZXgYASABKAUSHwoI",
"bWVzc2FnZXMYAiADKAsyDS5KTkZyYW1lSW5wdXQiLAoMSk5GcmFtZUluZm9z",
"EhwKBmZyYW1lcxgBIAMoCzIMLkpORnJhbWVJbmZvIisKB0pOSW5wdXQSFAoH",
"bWVzc2FnZRgBIAEoCUgAiAEBQgoKCF9tZXNzYWdlIikKC0pOU3RhdGVEYXRh",
"EhEKBGRhdGEYAiABKAxIAIgBAUIHCgVfZGF0YSKPAQoOSk5TdGF0ZUFsbERh",
"dGESDQoFTmV0SUQYASABKAUSLwoIbWVzc2FnZXMYAiADKAsyHS5KTlN0YXRl",
"QWxsRGF0YS5NZXNzYWdlc0VudHJ5Gj0KDU1lc3NhZ2VzRW50cnkSCwoDa2V5",
"GAEgASgDEhsKBXZhbHVlGAIgASgLMgwuSk5TdGF0ZURhdGE6AjgBIpEBCg9K",
"TlN0YXRlSXRlbURhdGESDQoFTmV0SUQYASABKAUSMAoIbWVzc2FnZXMYAiAD",
"KAsyHi5KTlN0YXRlSXRlbURhdGEuTWVzc2FnZXNFbnRyeRo9Cg1NZXNzYWdl",
"c0VudHJ5EgsKA2tleRgBIAEoAxIbCgV2YWx1ZRgCIAEoCzIMLkpOU3RhdGVE",
"YXRhOgI4ASJBChFKTlN0YXRlVGlsZUlucHV0cxILCgN0SWQYASABKAUSHwoH",
"bWVzc2FnZRgCIAEoCzIOLkpORnJhbWVJbnB1dHMiQgoTSk5TdGF0ZVRpbGVJ",
"dGVtRGF0YRILCgN0SWQYASABKAUSHgoEZGF0YRgCIAEoCzIQLkpOU3RhdGVJ",
"dGVtRGF0YSJAChJKTlN0YXRlVGlsZUFsbERhdGESCwoDdElkGAEgASgFEh0K",
"BGRhdGEYAiABKAsyDy5KTlN0YXRlQWxsRGF0YSI5Cg9KTkFkZFRpbGVTZXJ2",
"ZXISDAoEdGlsZRgBIAEoBRIKCgJpcBgCIAEoCRIMCgRwb3J0GAMgASgFQhYK",
"FGNuLmppc29sLm5nYW1lLnByb3RvYgZwcm90bzM="));
"ChNKTlN5bmNNZXNzYWdlLnByb3RvIiMKD0pOQ2xpZW50Q29ubmVjdBIQCghj",
"bGllbnRJZBgBIAEoCSImChJKTkNsaWVudERpc2Nvbm5lY3QSEAoIY2xpZW50",
"SWQYASABKAkiSwoMSk5GcmFtZUlucHV0EgsKA25JZBgBIAEoBRISCgVpbnB1",
"dBgCIAEoDEgAiAEBEhAKCGNsaWVudElkGAMgASgFQggKBl9pbnB1dCIuCg1K",
"TkZyYW1lSW5wdXRzEh0KBmlucHV0cxgBIAMoCzINLkpORnJhbWVJbnB1dCI9",
"CgtKTkZyYW1lSW5mbxINCgVpbmRleBgBIAEoBRIfCghtZXNzYWdlcxgCIAMo",
"CzINLkpORnJhbWVJbnB1dCIsCgxKTkZyYW1lSW5mb3MSHAoGZnJhbWVzGAEg",
"AygLMgwuSk5GcmFtZUluZm8iKwoHSk5JbnB1dBIUCgdtZXNzYWdlGAEgASgJ",
"SACIAQFCCgoIX21lc3NhZ2UiKQoLSk5TdGF0ZURhdGESEQoEZGF0YRgCIAEo",
"DEgAiAEBQgcKBV9kYXRhIo8BCg5KTlN0YXRlQWxsRGF0YRINCgVOZXRJRBgB",
"IAEoBRIvCghtZXNzYWdlcxgCIAMoCzIdLkpOU3RhdGVBbGxEYXRhLk1lc3Nh",
"Z2VzRW50cnkaPQoNTWVzc2FnZXNFbnRyeRILCgNrZXkYASABKAMSGwoFdmFs",
"dWUYAiABKAsyDC5KTlN0YXRlRGF0YToCOAEikQEKD0pOU3RhdGVJdGVtRGF0",
"YRINCgVOZXRJRBgBIAEoBRIwCghtZXNzYWdlcxgCIAMoCzIeLkpOU3RhdGVJ",
"dGVtRGF0YS5NZXNzYWdlc0VudHJ5Gj0KDU1lc3NhZ2VzRW50cnkSCwoDa2V5",
"GAEgASgDEhsKBXZhbHVlGAIgASgLMgwuSk5TdGF0ZURhdGE6AjgBIkEKEUpO",
"U3RhdGVUaWxlSW5wdXRzEgsKA3RJZBgBIAEoBRIfCgdtZXNzYWdlGAIgASgL",
"Mg4uSk5GcmFtZUlucHV0cyJCChNKTlN0YXRlVGlsZUl0ZW1EYXRhEgsKA3RJ",
"ZBgBIAEoBRIeCgRkYXRhGAIgASgLMhAuSk5TdGF0ZUl0ZW1EYXRhIkAKEkpO",
"U3RhdGVUaWxlQWxsRGF0YRILCgN0SWQYASABKAUSHQoEZGF0YRgCIAEoCzIP",
"LkpOU3RhdGVBbGxEYXRhIjkKD0pOQWRkVGlsZVNlcnZlchIMCgR0aWxlGAEg",
"ASgFEgoKAmlwGAIgASgJEgwKBHBvcnQYAyABKAVCFgoUY24uamlzb2wubmdh",
"bWUucHJvdG9iBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::JNClientConnect), global::JNClientConnect.Parser, new[]{ "ClientId" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::JNClientDisconnect), global::JNClientDisconnect.Parser, new[]{ "ClientId" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::JNFrameInput), global::JNFrameInput.Parser, new[]{ "NId", "Input", "ClientId" }, new[]{ "Input" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::JNFrameInputs), global::JNFrameInputs.Parser, new[]{ "Inputs" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::JNFrameInfo), global::JNFrameInfo.Parser, new[]{ "Index", "Messages" }, null, null, null, null),
@@ -64,6 +68,397 @@ public static partial class JNSyncMessageReflection {
}
#region Messages
/// <summary>
/// ---------------------- 状态 --------------------------
///连接客户端
/// </summary>
public sealed partial class JNClientConnect : pb::IMessage<JNClientConnect>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<JNClientConnect> _parser = new pb::MessageParser<JNClientConnect>(() => new JNClientConnect());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pb::MessageParser<JNClientConnect> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[0]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public JNClientConnect() {
OnConstruction();
}
partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public JNClientConnect(JNClientConnect other) : this() {
clientId_ = other.clientId_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public JNClientConnect Clone() {
return new JNClientConnect(this);
}
/// <summary>Field number for the "clientId" field.</summary>
public const int ClientIdFieldNumber = 1;
private string clientId_ = "";
/// <summary>
///客户端Id
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public string ClientId {
get { return clientId_; }
set {
clientId_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override bool Equals(object other) {
return Equals(other as JNClientConnect);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool Equals(JNClientConnect other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (ClientId != other.ClientId) return false;
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override int GetHashCode() {
int hash = 1;
if (ClientId.Length != 0) hash ^= ClientId.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void WriteTo(pb::CodedOutputStream output) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (ClientId.Length != 0) {
output.WriteRawTag(10);
output.WriteString(ClientId);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (ClientId.Length != 0) {
output.WriteRawTag(10);
output.WriteString(ClientId);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
}
#endif
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public int CalculateSize() {
int size = 0;
if (ClientId.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(ClientId);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void MergeFrom(JNClientConnect other) {
if (other == null) {
return;
}
if (other.ClientId.Length != 0) {
ClientId = other.ClientId;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void MergeFrom(pb::CodedInputStream input) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
input.ReadRawMessage(this);
#else
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
ClientId = input.ReadString();
break;
}
}
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 10: {
ClientId = input.ReadString();
break;
}
}
}
}
#endif
}
/// <summary>
///断开客户端
/// </summary>
public sealed partial class JNClientDisconnect : pb::IMessage<JNClientDisconnect>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<JNClientDisconnect> _parser = new pb::MessageParser<JNClientDisconnect>(() => new JNClientDisconnect());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pb::MessageParser<JNClientDisconnect> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[1]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public JNClientDisconnect() {
OnConstruction();
}
partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public JNClientDisconnect(JNClientDisconnect other) : this() {
clientId_ = other.clientId_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public JNClientDisconnect Clone() {
return new JNClientDisconnect(this);
}
/// <summary>Field number for the "clientId" field.</summary>
public const int ClientIdFieldNumber = 1;
private string clientId_ = "";
/// <summary>
///客户端Id
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public string ClientId {
get { return clientId_; }
set {
clientId_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override bool Equals(object other) {
return Equals(other as JNClientDisconnect);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool Equals(JNClientDisconnect other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (ClientId != other.ClientId) return false;
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override int GetHashCode() {
int hash = 1;
if (ClientId.Length != 0) hash ^= ClientId.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void WriteTo(pb::CodedOutputStream output) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (ClientId.Length != 0) {
output.WriteRawTag(10);
output.WriteString(ClientId);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (ClientId.Length != 0) {
output.WriteRawTag(10);
output.WriteString(ClientId);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
}
#endif
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public int CalculateSize() {
int size = 0;
if (ClientId.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(ClientId);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void MergeFrom(JNClientDisconnect other) {
if (other == null) {
return;
}
if (other.ClientId.Length != 0) {
ClientId = other.ClientId;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void MergeFrom(pb::CodedInputStream input) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
input.ReadRawMessage(this);
#else
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
ClientId = input.ReadString();
break;
}
}
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 10: {
ClientId = input.ReadString();
break;
}
}
}
}
#endif
}
/// <summary>
/// ---------------------- 帧同步 --------------------------
///帧同步输入
@@ -82,7 +477,7 @@ public sealed partial class JNFrameInput : pb::IMessage<JNFrameInput>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[0]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[2]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -369,7 +764,7 @@ public sealed partial class JNFrameInputs : pb::IMessage<JNFrameInputs>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[1]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[3]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -553,7 +948,7 @@ public sealed partial class JNFrameInfo : pb::IMessage<JNFrameInfo>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[2]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[4]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -777,7 +1172,7 @@ public sealed partial class JNFrameInfos : pb::IMessage<JNFrameInfos>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[3]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[5]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -961,7 +1356,7 @@ public sealed partial class JNInput : pb::IMessage<JNInput>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[4]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[6]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1166,7 +1561,7 @@ public sealed partial class JNStateData : pb::IMessage<JNStateData>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[5]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[7]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1373,7 +1768,7 @@ public sealed partial class JNStateAllData : pb::IMessage<JNStateAllData>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[6]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[8]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1597,7 +1992,7 @@ public sealed partial class JNStateItemData : pb::IMessage<JNStateItemData>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[7]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[9]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -1822,7 +2217,7 @@ public sealed partial class JNStateTileInputs : pb::IMessage<JNStateTileInputs>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[8]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[10]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2066,7 +2461,7 @@ public sealed partial class JNStateTileItemData : pb::IMessage<JNStateTileItemDa
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[9]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[11]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2307,7 +2702,7 @@ public sealed partial class JNStateTileAllData : pb::IMessage<JNStateTileAllData
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[10]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[12]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -2548,7 +2943,7 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public static pbr::MessageDescriptor Descriptor {
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[11]; }
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[13]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]

View File

@@ -2,6 +2,17 @@ syntax = "proto3";
option java_package = "cn.jisol.ngame.proto";
// ---------------------- 状态 --------------------------
//连接客户端
message JNClientConnect{
string clientId = 1; //客户端Id
}
//断开客户端
message JNClientDisconnect{
string clientId = 1; //客户端Id
}
// ---------------------- 帧同步 --------------------------
//帧同步输入
message JNFrameInput{

View File

@@ -47,8 +47,12 @@ namespace JNGame.Sync.System.Data
//如果有则删除
if (lIsTileData.Remove(child.Id,out var data))
{
//并且同步属性到实体
child.TileSyncData(data);
//同步不属于自己的实体
if (!child.IsHost)
{
//并且同步属性到实体中
child.TileSyncData(data);
}
}
});

View File

@@ -42,7 +42,6 @@ namespace Plugins.JNGame.Util
{
var request = UnityWebRequest.Get($"{this._config.BaseURL}/{url}");
var text = (await request.SendWebRequest()).downloadHandler.text;
Debug.Log(text);
return JsonConvert.DeserializeObject<NewsContext<T>>(text);
}

View File

@@ -177,13 +177,13 @@ namespace AppGame.Sync
if (IsTileConnect(index))
{
Debug.Log($"[{index}] 连接 Socket");
App.Client.AddClient(client);
}
}
else
{
Sockets.Remove(index);
Debug.Log("获取连接失败");
}
}
@@ -192,6 +192,7 @@ namespace AppGame.Sync
{
if (Sockets.TryGetValue(index,out var client))
{
Debug.Log($"[{index}] 卸载 Socket");
App.Client.RemoveClient(client);
}
Sockets.Remove(index);

View File

@@ -128,11 +128,14 @@ namespace AppGame.Sync
{
//插入未处理输入
foreach (var input in Inputs)
lock (Inputs)
{
GetSystem<DInputSystem>().Enqueue(input);
foreach (var input in Inputs)
{
GetSystem<DInputSystem>().Enqueue(input);
}
Inputs.Clear();
}
Inputs.Clear();
base.OnRunSimulate();
}
@@ -202,13 +205,13 @@ namespace AppGame.Sync
TileServerInfo info = message.data;
if (info is not null)
{
Debug.Log($"[{index}] 连接 Socket");
client.SetPoint($"{info.ip}:{info.port}");
await client.OnInit();
}
else
{
Sockets.Remove(index);
Debug.Log("获取连接失败");
}
}
@@ -217,6 +220,7 @@ namespace AppGame.Sync
{
if (Sockets.TryGetValue(index,out var client))
{
Debug.Log($"[{index}] 卸载 Socket");
client.OnClose();
}
Sockets.Remove(index);

View File

@@ -35,7 +35,7 @@ namespace AppGame.Systems
//监听服务端事件
AddListener((int)NActionEnum.NSyncStateDataUpdate,OnNSyncStateDataUpdate);
AddListener((int)NActionEnum.ClientConnect,OnClientConnect);
AddListener((int)NActionEnum.LocalClientConnect,OnClientConnect);
//连接
await base.OnInit();

View File

@@ -78,7 +78,6 @@ namespace Game.JNGState.Logic.Data
if (bytes.Length == 0) return;
var value = JsonConvert.DeserializeObject<EDNodeValue>(Encoding.UTF8.GetString(bytes));
if (value.Position is not null) Value.Position = value.Position;
}
}
public class EDNodeDataSystem : DStateDataSystem<EDNodeData,EDNode>
@@ -97,6 +96,11 @@ namespace Game.JNGState.Logic.Data
var nodes = new Dictionary<long, EDNodeData>();
NodeContext.GetEntities().ForEach(child =>
{
if (nodes.ContainsKey(child.Id))
{
Debug.Log($"[EDNodeDataSystem] 出错 发现重复Key");
return;
}
nodes.Add(child.Id,new EDNodeData(child));
});
return nodes;

View File

@@ -21,5 +21,6 @@ namespace Game.JNGFrame.Logic.Entity.Components
base.BindType(types);
types.Add(Movement,typeof(EDMoveComponent));
}
}
}

View File

@@ -36,6 +36,7 @@ namespace Game.JNGFrame.View.Entity
{
view.transform.DOKill();
view.transform.DOMove(data.Value.Position.ToVector3(), 0.5f);
// view.transform.position = data.Value.Position.ToVector3();
// view.transform.DOKill();
// view.transform.DOMove(pos = pos + new Vector3(0,0,10f / 15), 0.07f);
}

View File

@@ -46,7 +46,6 @@ namespace UI
};
if (App.Game.IsStartGame)
{
Debug.Log($"{vector.X} {vector.Y}");
App.Game.GetInput<IDPlayer>().MoveVector = vector;
}