added fixes from pull #1
This commit is contained in:
parent
1957cf2bfb
commit
98416af0af
10 changed files with 164 additions and 196 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using FishNet.Managing;
|
using FishNet.Managing;
|
||||||
using FishNet.Managing.Logging;
|
using FishNet.Managing.Logging;
|
||||||
|
using FishNet.Managing.Server;
|
||||||
using FishNet.Serializing;
|
using FishNet.Serializing;
|
||||||
using FishNet.Transporting;
|
using FishNet.Transporting;
|
||||||
using FishNet.Utility.Extension;
|
using FishNet.Utility.Extension;
|
||||||
|
|
@ -18,160 +19,180 @@ namespace FishBait
|
||||||
[DefaultExecutionOrder(1001)]
|
[DefaultExecutionOrder(1001)]
|
||||||
public partial class FishBaitTransport : Transport
|
public partial class FishBaitTransport : Transport
|
||||||
{
|
{
|
||||||
#region Forward everything to Transport
|
public override bool Equals(object other)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public override event Action<ClientConnectionStateArgs> OnClientConnectionState
|
|
||||||
{
|
{
|
||||||
add
|
return base.Equals(other);
|
||||||
{
|
|
||||||
transport.OnClientConnectionState += value;
|
|
||||||
}
|
|
||||||
|
|
||||||
remove
|
|
||||||
{
|
|
||||||
transport.OnClientConnectionState -= value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override event Action<ServerConnectionStateArgs> OnServerConnectionState
|
public override string GetClientAddress()
|
||||||
{
|
{
|
||||||
add
|
return base.GetClientAddress();
|
||||||
{
|
|
||||||
transport.OnServerConnectionState += value;
|
|
||||||
}
|
|
||||||
|
|
||||||
remove
|
|
||||||
{
|
|
||||||
transport.OnServerConnectionState -= value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override event Action<RemoteConnectionStateArgs> OnRemoteConnectionState
|
|
||||||
{
|
|
||||||
add
|
|
||||||
{
|
|
||||||
transport.OnRemoteConnectionState += value;
|
|
||||||
}
|
|
||||||
|
|
||||||
remove
|
|
||||||
{
|
|
||||||
transport.OnRemoteConnectionState -= value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override event Action<ClientReceivedDataArgs> OnClientReceivedData
|
|
||||||
{
|
|
||||||
add
|
|
||||||
{
|
|
||||||
transport.OnClientReceivedData += value;
|
|
||||||
}
|
|
||||||
|
|
||||||
remove
|
|
||||||
{
|
|
||||||
transport.OnClientReceivedData -= value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override event Action<ServerReceivedDataArgs> OnServerReceivedData
|
|
||||||
{
|
|
||||||
add
|
|
||||||
{
|
|
||||||
transport.OnServerReceivedData += value;
|
|
||||||
}
|
|
||||||
|
|
||||||
remove
|
|
||||||
{
|
|
||||||
transport.OnServerReceivedData -= value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetConnectionAddress(int connectionId)
|
public override string GetConnectionAddress(int connectionId)
|
||||||
{
|
{
|
||||||
return transport.GetConnectionAddress(connectionId);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override LocalConnectionState GetConnectionState(bool server)
|
public override LocalConnectionState GetConnectionState(bool server)
|
||||||
{
|
{
|
||||||
return transport.GetConnectionState(server);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override RemoteConnectionState GetConnectionState(int connectionId)
|
public override RemoteConnectionState GetConnectionState(int connectionId)
|
||||||
{
|
{
|
||||||
return transport.GetConnectionState(connectionId);
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return base.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetMaximumClients()
|
||||||
|
{
|
||||||
|
return base.GetMaximumClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetMTU(byte channel)
|
public override int GetMTU(byte channel)
|
||||||
{
|
{
|
||||||
return transport.GetMTU(channel);
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ushort GetPort()
|
||||||
|
{
|
||||||
|
return base.GetPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetServerBindAddress()
|
||||||
|
{
|
||||||
|
return base.GetServerBindAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string GetServerBindAddress(IPAddressType addressType)
|
||||||
|
{
|
||||||
|
return base.GetServerBindAddress(addressType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override float GetTimeout(bool asServer)
|
||||||
|
{
|
||||||
|
return base.GetTimeout(asServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleClientConnectionState(ClientConnectionStateArgs connectionStateArgs)
|
public override void HandleClientConnectionState(ClientConnectionStateArgs connectionStateArgs)
|
||||||
{
|
{
|
||||||
transport.HandleClientConnectionState(connectionStateArgs);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleClientReceivedDataArgs(ClientReceivedDataArgs receivedDataArgs)
|
public override void HandleClientReceivedDataArgs(ClientReceivedDataArgs receivedDataArgs)
|
||||||
{
|
{
|
||||||
transport.HandleClientReceivedDataArgs(receivedDataArgs);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleRemoteConnectionState(RemoteConnectionStateArgs connectionStateArgs)
|
public override void HandleRemoteConnectionState(RemoteConnectionStateArgs connectionStateArgs)
|
||||||
{
|
{
|
||||||
transport.HandleRemoteConnectionState(connectionStateArgs);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleServerConnectionState(ServerConnectionStateArgs connectionStateArgs)
|
public override void HandleServerConnectionState(ServerConnectionStateArgs connectionStateArgs)
|
||||||
{
|
{
|
||||||
transport.HandleServerConnectionState(connectionStateArgs);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleServerReceivedDataArgs(ServerReceivedDataArgs receivedDataArgs)
|
public override void HandleServerReceivedDataArgs(ServerReceivedDataArgs receivedDataArgs)
|
||||||
{
|
{
|
||||||
transport.HandleServerReceivedDataArgs(receivedDataArgs);
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Initialize(NetworkManager networkManager, int transportIndex)
|
||||||
|
{
|
||||||
|
base.Initialize(networkManager, transportIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsLocalTransport(int connectionid)
|
||||||
|
{
|
||||||
|
return base.IsLocalTransport(connectionid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void IterateIncoming(bool server)
|
public override void IterateIncoming(bool server)
|
||||||
{
|
{
|
||||||
transport.IterateIncoming(server);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void IterateOutgoing(bool server)
|
public override void IterateOutgoing(bool server)
|
||||||
{
|
{
|
||||||
transport.IterateOutgoing(server);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SendToClient(byte channelId, ArraySegment<byte> segment, int connectionId)
|
public override void SendToClient(byte channelId, ArraySegment<byte> segment, int connectionId)
|
||||||
{
|
{
|
||||||
transport.SendToClient(channelId, segment, connectionId);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SendToServer(byte channelId, ArraySegment<byte> segment)
|
public override void SendToServer(byte channelId, ArraySegment<byte> segment)
|
||||||
{
|
{
|
||||||
transport.SendToServer(channelId, segment);
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetClientAddress(string address)
|
||||||
|
{
|
||||||
|
base.SetClientAddress(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetMaximumClients(int value)
|
||||||
|
{
|
||||||
|
base.SetMaximumClients(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetPort(ushort port)
|
||||||
|
{
|
||||||
|
base.SetPort(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetServerBindAddress(string address)
|
||||||
|
{
|
||||||
|
base.SetServerBindAddress(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetServerBindAddress(string address, IPAddressType addressType)
|
||||||
|
{
|
||||||
|
base.SetServerBindAddress(address, addressType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetTimeout(float value, bool asServer)
|
||||||
|
{
|
||||||
|
base.SetTimeout(value, asServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTransportPort(ushort port)
|
||||||
|
{
|
||||||
|
transport.SetPort(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
{
|
{
|
||||||
transport.Shutdown();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool StartConnection(bool server)
|
public override bool StartConnection(bool server)
|
||||||
{
|
{
|
||||||
return transport.StartConnection(server);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool StopConnection(bool server)
|
public override bool StopConnection(bool server)
|
||||||
{
|
{
|
||||||
return transport.StopConnection(server);
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool StopConnection(int connectionId, bool immediately)
|
public override bool StopConnection(int connectionId, bool immediately)
|
||||||
{
|
{
|
||||||
return transport.StopConnection(connectionId, immediately);
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return base.ToString();
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Called by Transport when a new client connected to the server.</summary>
|
/// <summary>Called by Transport when a new client connected to the server.</summary>
|
||||||
|
|
@ -186,10 +207,14 @@ namespace FishBait
|
||||||
public Action OnClientConnected = () => Debug.LogWarning("OnClientConnected called with no handler");
|
public Action OnClientConnected = () => Debug.LogWarning("OnClientConnected called with no handler");
|
||||||
/// <summary>Called by Transport when the client disconnected from the server.</summary>
|
/// <summary>Called by Transport when the client disconnected from the server.</summary>
|
||||||
public Action OnClientDisconnected = () => Debug.LogWarning("OnClientDisconnected called with no handler");
|
public Action OnClientDisconnected = () => Debug.LogWarning("OnClientDisconnected called with no handler");
|
||||||
public void SetTransportPort(ushort port)
|
|
||||||
{
|
public override event Action<ClientConnectionStateArgs> OnClientConnectionState;
|
||||||
transport.SetPort(port);
|
public override event Action<ServerConnectionStateArgs> OnServerConnectionState;
|
||||||
}
|
public override event Action<RemoteConnectionStateArgs> OnRemoteConnectionState;
|
||||||
|
public override event Action<ClientReceivedDataArgs> OnClientReceivedData;
|
||||||
|
public override event Action<ServerReceivedDataArgs> OnServerReceivedData;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System.Net;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using FishNet.Transporting;
|
using FishNet.Transporting;
|
||||||
|
using FishNet.Transporting.Multipass;
|
||||||
|
|
||||||
namespace FishBait
|
namespace FishBait
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using System.Net.Sockets;
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using FishNet.Transporting;
|
using FishNet.Transporting;
|
||||||
|
using FishNet.Transporting.Multipass;
|
||||||
|
|
||||||
namespace FishBait
|
namespace FishBait
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -497,7 +497,7 @@ Transform:
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 1516572637330113619}
|
m_Father: {fileID: 1516572637330113619}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &1172724428
|
--- !u!1 &1172724428
|
||||||
GameObject:
|
GameObject:
|
||||||
|
|
@ -691,57 +691,6 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
functionDisplay: {fileID: 278665276}
|
functionDisplay: {fileID: 278665276}
|
||||||
--- !u!1 &1287384425
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1287384427}
|
|
||||||
- component: {fileID: 1287384426}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: FishBait - Direct Connect
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!114 &1287384426
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1287384425}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 6f48f002b825cbd45a19bd96d90f9edb, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
_unreliableMTU: 1023
|
|
||||||
_ipv4BindAddress:
|
|
||||||
_ipv6BindAddress:
|
|
||||||
_port: 7770
|
|
||||||
_maximumClients: 4095
|
|
||||||
_clientAddress: localhost
|
|
||||||
_timeout: 15
|
|
||||||
--- !u!4 &1287384427
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1287384425}
|
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 1516572637330113619}
|
|
||||||
m_RootOrder: 1
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!224 &905488192866952489
|
--- !u!224 &905488192866952489
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -793,7 +742,6 @@ GameObject:
|
||||||
- component: {fileID: 8234759579310384502}
|
- component: {fileID: 8234759579310384502}
|
||||||
- component: {fileID: 1516572637330113630}
|
- component: {fileID: 1516572637330113630}
|
||||||
- component: {fileID: 8234759579310384505}
|
- component: {fileID: 8234759579310384505}
|
||||||
- component: {fileID: 8234759579310384507}
|
|
||||||
- component: {fileID: 8234759579310384506}
|
- component: {fileID: 8234759579310384506}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: FishNetworkManager
|
m_Name: FishNetworkManager
|
||||||
|
|
@ -815,7 +763,6 @@ Transform:
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 5670112771492132974}
|
- {fileID: 5670112771492132974}
|
||||||
- {fileID: 1287384427}
|
|
||||||
- {fileID: 1094339531}
|
- {fileID: 1094339531}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 4
|
||||||
|
|
@ -1383,7 +1330,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 34e4a322dca349547989b14021da4e23, type: 3}
|
m_Script: {fileID: 11500000, guid: 34e4a322dca349547989b14021da4e23, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
Transport: {fileID: 8234759579310384507}
|
Transport: {fileID: 8234759579310384506}
|
||||||
_latencySimulator:
|
_latencySimulator:
|
||||||
_enabled: 0
|
_enabled: 0
|
||||||
_simulateHost: 1
|
_simulateHost: 1
|
||||||
|
|
@ -1399,48 +1346,9 @@ MonoBehaviour:
|
||||||
m_GameObject: {fileID: 1516572637330113617}
|
m_GameObject: {fileID: 1516572637330113617}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 21eba6e2b0a7e964eb29db14a4eae4d6, type: 3}
|
m_Script: {fileID: 11500000, guid: 314b449d3505bd24487ba69b61c2fda5, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
directConnectTransport: {fileID: 1287384426}
|
GlobalServerActions: 1
|
||||||
showDebugLogs: 0
|
_transports:
|
||||||
--- !u!114 &8234759579310384507
|
- {fileID: 1094339530}
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1516572637330113617}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 37bf248b7e575fe4592c1ec247b10573, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
transport: {fileID: 1094339530}
|
|
||||||
serverIP: 129.151.223.167
|
|
||||||
serverPort: 7777
|
|
||||||
endpointServerPort: 8080
|
|
||||||
heartBeatInterval: 3
|
|
||||||
connectOnAwake: 1
|
|
||||||
authenticationKey: Secret Auth Key
|
|
||||||
disconnectedFromRelay:
|
|
||||||
m_PersistentCalls:
|
|
||||||
m_Calls: []
|
|
||||||
connectedToRelay:
|
|
||||||
m_PersistentCalls:
|
|
||||||
m_Calls: []
|
|
||||||
useNATPunch: 1
|
|
||||||
NATPunchtroughPort: 1
|
|
||||||
useLoadBalancer: 0
|
|
||||||
loadBalancerPort: 7070
|
|
||||||
loadBalancerAddress: 127.0.0.1
|
|
||||||
serverName: My awesome server!
|
|
||||||
extraServerData: Map 1
|
|
||||||
maxServerPlayers: 10
|
|
||||||
isPublicServer: 1
|
|
||||||
serverListUpdated:
|
|
||||||
m_PersistentCalls:
|
|
||||||
m_Calls: []
|
|
||||||
serverStatus: Not Started.
|
|
||||||
serverId:
|
|
||||||
region: 1
|
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,10 @@ namespace LightReflectiveMirror.LoadBalancing
|
||||||
public string serverName;
|
public string serverName;
|
||||||
public string serverData;
|
public string serverData;
|
||||||
public bool isPublic;
|
public bool isPublic;
|
||||||
public int currentPlayers { get => clients.Count + 1; }
|
|
||||||
public int maxPlayers;
|
public int maxPlayers;
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public List<int> clients;
|
|
||||||
|
|
||||||
public RelayAddress relayInfo;
|
public RelayAddress relayInfo;
|
||||||
|
public int currentPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum LRMRegions { Any, NorthAmerica, SouthAmerica, Europe, Asia, Africa, Oceania }
|
public enum LRMRegions { Any, NorthAmerica, SouthAmerica, Europe, Asia, Africa, Oceania }
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ namespace LightReflectiveMirror.LoadBalancing
|
||||||
Logger.ForceLogMessage("Conflicting Rooms! (That's ok)", ConsoleColor.Yellow);
|
Logger.ForceLogMessage("Conflicting Rooms! (That's ok)", ConsoleColor.Yellow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.WriteLogMessage($"Try Calling CacheAllServers", ConsoleColor.Cyan);
|
||||||
CacheAllServers();
|
CacheAllServers();
|
||||||
await context.Response.SendResponseAsync(HttpStatusCode.Ok);
|
await context.Response.SendResponseAsync(HttpStatusCode.Ok);
|
||||||
}
|
}
|
||||||
|
|
@ -168,12 +169,18 @@ namespace LightReflectiveMirror.LoadBalancing
|
||||||
{
|
{
|
||||||
string region = context.Request.Headers["x-Region"];
|
string region = context.Request.Headers["x-Region"];
|
||||||
|
|
||||||
if (int.TryParse(region, out int regionID))
|
|
||||||
|
if (int.TryParse("Info:" + region, out int regionID))
|
||||||
{
|
{
|
||||||
|
Logger.WriteLogMessage("Send Servers, " + _regionRooms[(LRMRegions)regionID].Count, ConsoleColor.Cyan);
|
||||||
|
Logger.WriteLogMessage("Send Servers(Cached), " + _cachedRegionRooms[(LRMRegions)regionID], ConsoleColor.Cyan);
|
||||||
await context.Response.SendResponseAsync(_cachedRegionRooms[(LRMRegions)regionID]);
|
await context.Response.SendResponseAsync(_cachedRegionRooms[(LRMRegions)regionID]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.WriteLogMessage("Send Servers, "+_regionRooms[LRMRegions.Any].Count,ConsoleColor.Cyan);
|
||||||
|
Logger.WriteLogMessage("Send Servers(Cached), " + _cachedRegionRooms[LRMRegions.Any], ConsoleColor.Cyan);
|
||||||
|
|
||||||
// They didnt submit a region header, just give them all servers as they probably are viewing in browser.
|
// They didnt submit a region header, just give them all servers as they probably are viewing in browser.
|
||||||
await context.Response.SendResponseAsync(_cachedRegionRooms[LRMRegions.Any]);
|
await context.Response.SendResponseAsync(_cachedRegionRooms[LRMRegions.Any]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using Newtonsoft.Json;
|
using LightReflectiveMirror.Debug;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
|
@ -9,8 +11,16 @@ namespace LightReflectiveMirror.LoadBalancing
|
||||||
{
|
{
|
||||||
static void CacheAllServers()
|
static void CacheAllServers()
|
||||||
{
|
{
|
||||||
|
Logger.WriteLogMessage($"CacheAllServers[{_regionRooms.Count}]", ConsoleColor.Cyan);
|
||||||
|
|
||||||
foreach (var region in _regionRooms)
|
foreach (var region in _regionRooms)
|
||||||
_cachedRegionRooms[region.Key] = JsonConvert.SerializeObject(region.Value);
|
{
|
||||||
|
Logger.WriteLogMessage($"CacheAllServers[{region.Key}][{region.Value.Count}]", ConsoleColor.Cyan);
|
||||||
|
|
||||||
|
_cachedRegionRooms[region.Key] = JsonConvert.SerializeObject(region.Value,Formatting.Indented);
|
||||||
|
|
||||||
|
Logger.WriteLogMessage($"CacheAllServers[{region.Key}][{region.Value.Count}] {_cachedRegionRooms[region.Key]}", ConsoleColor.Cyan);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ClearAllServersLists()
|
static void ClearAllServersLists()
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ namespace LightReflectiveMirror.LoadBalancing
|
||||||
const string API_PATH = "/api/stats";
|
const string API_PATH = "/api/stats";
|
||||||
readonly string CONFIG_PATH = System.Environment.GetEnvironmentVariable("LRM_LB_CONFIG_PATH") ?? "config.json";
|
readonly string CONFIG_PATH = System.Environment.GetEnvironmentVariable("LRM_LB_CONFIG_PATH") ?? "config.json";
|
||||||
|
|
||||||
|
private Random _cachedRandom = new();
|
||||||
|
|
||||||
public static Config conf;
|
public static Config conf;
|
||||||
public static Program instance;
|
public static Program instance;
|
||||||
|
|
||||||
|
|
@ -157,6 +159,7 @@ namespace LightReflectiveMirror.LoadBalancing
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<List<Room>> RequestServerListFromNode(string serverIP, ushort port)
|
public async Task<List<Room>> RequestServerListFromNode(string serverIP, ushort port)
|
||||||
{
|
{
|
||||||
|
Logger.ForceLogMessage($"Request Server List from Node: {serverIP}:{port}", ConsoleColor.Yellow);
|
||||||
using (WebClient wc = new WebClient())
|
using (WebClient wc = new WebClient())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ namespace LightReflectiveMirror
|
||||||
/// <param name="clientId">The client requesting to create a room</param>
|
/// <param name="clientId">The client requesting to create a room</param>
|
||||||
/// <param name="maxPlayers">The maximum amount of players for this room</param>
|
/// <param name="maxPlayers">The maximum amount of players for this room</param>
|
||||||
/// <param name="serverName">The name for the server</param>
|
/// <param name="serverName">The name for the server</param>
|
||||||
/// <param name="isPublic">Weather or not the server should show up on the server list</param>
|
/// <param name="isPublic">Whether or not the server should show up on the server list</param>
|
||||||
/// <param name="serverData">Extra data the host can include</param>
|
/// <param name="serverData">Extra data the host can include</param>
|
||||||
/// <param name="useDirectConnect">Weather or not, the host is capable of doing direct connections</param>
|
/// <param name="useDirectConnect">Whether or not, the host is capable of doing direct connections</param>
|
||||||
/// <param name="hostLocalIP">The hosts local IP</param>
|
/// <param name="hostLocalIP">The hosts local IP</param>
|
||||||
/// <param name="useNatPunch">Weather or not, the host is supporting NAT Punch</param>
|
/// <param name="useNatPunch">Whether or not, the host is supporting NAT Punch</param>
|
||||||
/// <param name="port">The port of the direct connect transport on the host</param>
|
/// <param name="port">The port of the direct connect transport on the host</param>
|
||||||
private void CreateRoom(int clientId, int maxPlayers, string serverName, bool isPublic, string serverData, bool useDirectConnect, string hostLocalIP, bool useNatPunch, int port)
|
private void CreateRoom(int clientId, int maxPlayers, string serverName, bool isPublic, string serverData, bool useDirectConnect, string hostLocalIP, bool useNatPunch, int port)
|
||||||
{
|
{
|
||||||
|
|
@ -38,7 +38,7 @@ namespace LightReflectiveMirror
|
||||||
supportsDirectConnect = hostIP != null && useDirectConnect,
|
supportsDirectConnect = hostIP != null && useDirectConnect,
|
||||||
port = port,
|
port = port,
|
||||||
useNATPunch = useNatPunch,
|
useNATPunch = useNatPunch,
|
||||||
relayInfo = new RelayAddress { address = Program.publicIP, port = Program.conf.TransportPort, endpointPort = Program.conf.EndpointPort }
|
relayInfo = new RelayAddress { address = Program.publicIP, port = Program.conf.TransportPort, endpointPort = Program.conf.EndpointPort, serverRegion = Program.conf.LoadBalancerRegion }
|
||||||
};
|
};
|
||||||
|
|
||||||
rooms.Add(room);
|
rooms.Add(room);
|
||||||
|
|
@ -98,7 +98,7 @@ namespace LightReflectiveMirror
|
||||||
{
|
{
|
||||||
sendJoinPos = 0;
|
sendJoinPos = 0;
|
||||||
sendJoinBuffer.WriteByte(ref sendJoinPos, (byte)OpCodes.DirectConnectIP);
|
sendJoinBuffer.WriteByte(ref sendJoinPos, (byte)OpCodes.DirectConnectIP);
|
||||||
Console.WriteLine(Program.instance.NATConnections[clientId].Address.ToString());
|
|
||||||
sendJoinBuffer.WriteString(ref sendJoinPos, Program.instance.NATConnections[clientId].Address.ToString());
|
sendJoinBuffer.WriteString(ref sendJoinPos, Program.instance.NATConnections[clientId].Address.ToString());
|
||||||
sendJoinBuffer.WriteInt(ref sendJoinPos, Program.instance.NATConnections[clientId].Port);
|
sendJoinBuffer.WriteInt(ref sendJoinPos, Program.instance.NATConnections[clientId].Port);
|
||||||
sendJoinBuffer.WriteBool(ref sendJoinPos, true);
|
sendJoinBuffer.WriteBool(ref sendJoinPos, true);
|
||||||
|
|
@ -145,6 +145,7 @@ namespace LightReflectiveMirror
|
||||||
{
|
{
|
||||||
for (int i = 0; i < rooms.Count; i++)
|
for (int i = 0; i < rooms.Count; i++)
|
||||||
{
|
{
|
||||||
|
// if host left
|
||||||
if (rooms[i].hostId == clientId)
|
if (rooms[i].hostId == clientId)
|
||||||
{
|
{
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
@ -167,6 +168,7 @@ namespace LightReflectiveMirror
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// if the person that tried to kick wasnt host and it wasnt the client leaving on their own
|
||||||
if (requiredHostId != -1 && rooms[i].hostId != requiredHostId)
|
if (requiredHostId != -1 && rooms[i].hostId != requiredHostId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -180,6 +182,19 @@ namespace LightReflectiveMirror
|
||||||
|
|
||||||
Program.transport.ServerSend(rooms[i].hostId, 0, new ArraySegment<byte>(sendBuffer, 0, pos));
|
Program.transport.ServerSend(rooms[i].hostId, 0, new ArraySegment<byte>(sendBuffer, 0, pos));
|
||||||
_sendBuffers.Return(sendBuffer);
|
_sendBuffers.Return(sendBuffer);
|
||||||
|
|
||||||
|
// temporary solution to kicking bug
|
||||||
|
// this tells the local player that got kicked that he, well, got kicked.
|
||||||
|
pos = 0;
|
||||||
|
sendBuffer = _sendBuffers.Rent(1);
|
||||||
|
|
||||||
|
sendBuffer.WriteByte(ref pos, (byte)OpCodes.ServerLeft);
|
||||||
|
|
||||||
|
Program.transport.ServerSend(clientId, 0, new ArraySegment<byte>(sendBuffer, 0, pos));
|
||||||
|
_sendBuffers.Return(sendBuffer);
|
||||||
|
|
||||||
|
//end temporary solution
|
||||||
|
|
||||||
Endpoint.RoomsModified();
|
Endpoint.RoomsModified();
|
||||||
_cachedClientRooms.Remove(clientId);
|
_cachedClientRooms.Remove(clientId);
|
||||||
}
|
}
|
||||||
|
|
@ -187,4 +202,4 @@ namespace LightReflectiveMirror
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,5 +39,6 @@ namespace LightReflectiveMirror
|
||||||
public ushort port;
|
public ushort port;
|
||||||
public ushort endpointPort;
|
public ushort endpointPort;
|
||||||
public string address;
|
public string address;
|
||||||
|
public LRMRegions serverRegion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue