mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-11-11 08:38:45 +00:00
提交新概念 Tile从服务器
This commit is contained in:
@@ -48,6 +48,14 @@ namespace Plugins.JNGame.Network
|
||||
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
client.Close();
|
||||
client.Dispose();
|
||||
Debug.Log($"[JNTCPClient] 关闭对象");
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
private Task OnReceived(WebSocketClient webSocketClient, WSDataFrameEventArgs e)
|
||||
{
|
||||
if (e.DataFrame.Opcode == WSDataType.Binary && e.DataFrame.FIN)
|
||||
|
||||
@@ -46,10 +46,9 @@ namespace JNGame.Network
|
||||
/// <param name="e"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private Task OnConnecting(ITcpClient client, ConnectingEventArgs e)
|
||||
private async Task OnConnecting(ITcpClient client, ConnectingEventArgs e)
|
||||
{
|
||||
Debug.Log($"[JNTCPClient] 开始连接服务器");
|
||||
return Task.CompletedTask;
|
||||
Debug.Log($"[JNTCPClient] 开始连接服务器 {await GetEndPoint()}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,10 @@ namespace JNGame.Network
|
||||
service.Connected = OnConnected;//有客户端连接
|
||||
service.Disconnected = OnDisconnected;//有客户端断开连接
|
||||
service.Received = OnReceived;//客户端接收到消息
|
||||
|
||||
Debug.Log($"[JNTCPServer] 启动服务端中");
|
||||
await service.StartAsync(_port = await GetPort());//启动
|
||||
Debug.Log($"[JNTCPServer] 启动服务端成功");
|
||||
|
||||
}
|
||||
|
||||
@@ -139,11 +142,15 @@ namespace JNGame.Network
|
||||
service.SendAsync(client, bytes);
|
||||
}
|
||||
|
||||
public void AllSend(int hId,IMessage data = null)
|
||||
public void AllSend(int hId,IMessage data = null,Func<SocketClient,bool> filter = null)
|
||||
{
|
||||
filter ??= (SocketClient client) => true;
|
||||
service.GetClients().ForEach(client =>
|
||||
{
|
||||
Send(client,hId,data);
|
||||
if (filter(client))
|
||||
{
|
||||
Send(client, hId, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,10 @@ public static partial class JNSyncMessageReflection {
|
||||
"aWxlSW5wdXRzEgsKA3RJZBgBIAEoBRIfCgdtZXNzYWdlGAIgASgLMg4uSk5G",
|
||||
"cmFtZUlucHV0cyJAChJKTlN0YXRlVGlsZUFsbERhdGESCwoDdElkGAEgASgF",
|
||||
"Eh0KBGRhdGEYAiABKAsyDy5KTlN0YXRlQWxsRGF0YSIqChtOU3luY1RpbGVH",
|
||||
"ZXRUaWxlSW5mb1JlcXVlc3QSCwoDdElkGAEgASgFIjkKD0pOQWRkVGlsZVNl",
|
||||
"cnZlchIMCgR0aWxlGAEgASgFEgoKAmlwGAIgASgJEgwKBHBvcnQYAyABKAVC",
|
||||
"FgoUY24uamlzb2wubmdhbWUucHJvdG9iBnByb3RvMw=="));
|
||||
"ZXRUaWxlSW5mb1JlcXVlc3QSCwoDdElkGAEgASgFIkkKD0pOQWRkVGlsZVNl",
|
||||
"cnZlchIMCgR0aWxlGAEgASgFEgoKAmlwGAIgASgJEgwKBHBvcnQYAyABKAUS",
|
||||
"DgoGbWFzdGVyGAQgASgIQhYKFGNuLmppc29sLm5nYW1lLnByb3RvYgZwcm90",
|
||||
"bzM="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
@@ -58,7 +59,7 @@ public static partial class JNSyncMessageReflection {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNStateTileInputs), global::JNStateTileInputs.Parser, new[]{ "TId", "Message" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNStateTileAllData), global::JNStateTileAllData.Parser, new[]{ "TId", "Data" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::NSyncTileGetTileInfoRequest), global::NSyncTileGetTileInfoRequest.Parser, new[]{ "TId" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNAddTileServer), global::JNAddTileServer.Parser, new[]{ "Tile", "Ip", "Port" }, null, null, null, null)
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNAddTileServer), global::JNAddTileServer.Parser, new[]{ "Tile", "Ip", "Port", "Master" }, null, null, null, null)
|
||||
}));
|
||||
}
|
||||
#endregion
|
||||
@@ -2877,6 +2878,7 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
|
||||
tile_ = other.tile_;
|
||||
ip_ = other.ip_;
|
||||
port_ = other.port_;
|
||||
master_ = other.master_;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
@@ -2931,6 +2933,21 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "master" field.</summary>
|
||||
public const int MasterFieldNumber = 4;
|
||||
private bool master_;
|
||||
/// <summary>
|
||||
///是否是主服务器
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool Master {
|
||||
get { return master_; }
|
||||
set {
|
||||
master_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override bool Equals(object other) {
|
||||
@@ -2949,6 +2966,7 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
|
||||
if (Tile != other.Tile) return false;
|
||||
if (Ip != other.Ip) return false;
|
||||
if (Port != other.Port) return false;
|
||||
if (Master != other.Master) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
@@ -2959,6 +2977,7 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
|
||||
if (Tile != 0) hash ^= Tile.GetHashCode();
|
||||
if (Ip.Length != 0) hash ^= Ip.GetHashCode();
|
||||
if (Port != 0) hash ^= Port.GetHashCode();
|
||||
if (Master != false) hash ^= Master.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
@@ -2989,6 +3008,10 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
|
||||
output.WriteRawTag(24);
|
||||
output.WriteInt32(Port);
|
||||
}
|
||||
if (Master != false) {
|
||||
output.WriteRawTag(32);
|
||||
output.WriteBool(Master);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
@@ -3011,6 +3034,10 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
|
||||
output.WriteRawTag(24);
|
||||
output.WriteInt32(Port);
|
||||
}
|
||||
if (Master != false) {
|
||||
output.WriteRawTag(32);
|
||||
output.WriteBool(Master);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
@@ -3030,6 +3057,9 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
|
||||
if (Port != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(Port);
|
||||
}
|
||||
if (Master != false) {
|
||||
size += 1 + 1;
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
@@ -3051,6 +3081,9 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
|
||||
if (other.Port != 0) {
|
||||
Port = other.Port;
|
||||
}
|
||||
if (other.Master != false) {
|
||||
Master = other.Master;
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
@@ -3078,6 +3111,10 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
|
||||
Port = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 32: {
|
||||
Master = input.ReadBool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -3105,6 +3142,10 @@ public sealed partial class JNAddTileServer : pb::IMessage<JNAddTileServer>
|
||||
Port = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 32: {
|
||||
Master = input.ReadBool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,4 +80,5 @@ message JNAddTileServer{
|
||||
int32 tile = 1; //TileId
|
||||
string ip = 2; //IP
|
||||
int32 port = 3; //端口
|
||||
bool master = 4; //是否是主服务器
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user