浏览代码
feat : Working Callbacks!!!!
feat : Working Callbacks!!!!
-still need to remove commented out code/main/staging/2021_Upgrade/Async_Refactor
Jacob
2 年前
当前提交
e462c1d1
共有 16 个文件被更改,包括 662 次插入 和 629 次删除
-
2Assets/Prefabs/UI/LobbyUserList.prefab
-
2Assets/Prefabs/UI/UserCardPanel.prefab
-
20Assets/Scripts/GameLobby/Game/GameManager.cs
-
14Assets/Scripts/GameLobby/Game/LocalLobby.cs
-
6Assets/Scripts/GameLobby/Game/LocalPlayer.cs
-
27Assets/Scripts/GameLobby/Lobby/LobbyManager.cs
-
346Assets/Scripts/GameLobby/Lobby/LobbySynchronizer.cs
-
47Assets/Scripts/GameLobby/NGO/SetupInGame.cs
-
108Assets/Scripts/GameLobby/Relay/RelayPendingApproval.cs
-
434Assets/Scripts/GameLobby/Relay/RelayUtpHost.cs
-
4Assets/Scripts/GameLobby/Tests/PlayMode/LobbyRoundtripTests.cs
-
188Assets/Scripts/GameLobby/Tests/PlayMode/UtpTests.cs
-
30Assets/Scripts/GameLobby/UI/InLobbyUserUI.cs
-
10Assets/Scripts/GameLobby/UI/LobbyEntryUI.cs
-
45Assets/Scripts/GameLobby/UI/LobbyUserListUI.cs
-
8Assets/StreamingAssets.meta
|
|||
using System; |
|||
using Unity.Networking.Transport; |
|||
|
|||
namespace LobbyRelaySample.relay |
|||
{ |
|||
/// <summary>
|
|||
/// The Relay host doesn't need to know what might approve or disapprove of a pending connection, so this will
|
|||
/// broadcast a message that approval is being sought, and if nothing disapproves, the connection will be permitted.
|
|||
/// </summary>
|
|||
public class RelayPendingApproval : IDisposable |
|||
{ |
|||
NetworkConnection m_pendingConnection; |
|||
private bool m_hasDisposed = false; |
|||
private const float k_waitTime = 0.1f; |
|||
private Action<NetworkConnection, Approval> m_onResult; |
|||
public string ID { get; private set; } |
|||
|
|||
public RelayPendingApproval(NetworkConnection conn, Action<NetworkConnection, Approval> onResult, string id) |
|||
{ |
|||
m_pendingConnection = conn; |
|||
m_onResult = onResult; |
|||
ID = id; |
|||
Locator.Get.UpdateSlow.Subscribe(Approve, k_waitTime); |
|||
Locator.Get.Messenger.OnReceiveMessage(MessageType.ClientUserSeekingDisapproval, (Action<Approval>)Disapprove); |
|||
} |
|||
~RelayPendingApproval() { Dispose(); } |
|||
|
|||
private void Approve(float unused) |
|||
{ |
|||
try |
|||
{ m_onResult?.Invoke(m_pendingConnection, Approval.OK); |
|||
} |
|||
finally |
|||
{ Dispose(); |
|||
} |
|||
} |
|||
|
|||
public void Disapprove(Approval reason) |
|||
{ |
|||
try |
|||
{ m_onResult?.Invoke(m_pendingConnection, reason); |
|||
} |
|||
finally |
|||
{ Dispose(); |
|||
} |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
if (!m_hasDisposed) |
|||
{ |
|||
Locator.Get.UpdateSlow.Unsubscribe(Approve); |
|||
m_hasDisposed = true; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
// namespace LobbyRelaySample.relay
|
|||
// {
|
|||
// /// <summary>
|
|||
// /// The Relay host doesn't need to know what might approve or disapprove of a pending connection, so this will
|
|||
// /// broadcast a message that approval is being sought, and if nothing disapproves, the connection will be permitted.
|
|||
// /// </summary>
|
|||
// public class RelayPendingApproval : IDisposable
|
|||
// {
|
|||
// NetworkConnection m_pendingConnection;
|
|||
// private bool m_hasDisposed = false;
|
|||
// private const float k_waitTime = 0.1f;
|
|||
// private Action<NetworkConnection, Approval> m_onResult;
|
|||
// public string ID { get; private set; }
|
|||
//
|
|||
// public RelayPendingApproval(NetworkConnection conn, Action<NetworkConnection, Approval> onResult, string id)
|
|||
// {
|
|||
// m_pendingConnection = conn;
|
|||
// m_onResult = onResult;
|
|||
// ID = id;
|
|||
// Locator.Get.UpdateSlow.Subscribe(Approve, k_waitTime);
|
|||
// Locator.Get.Messenger.OnReceiveMessage(MessageType.ClientUserSeekingDisapproval, (Action<Approval>)Disapprove);
|
|||
// }
|
|||
// ~RelayPendingApproval() { Dispose(); }
|
|||
//
|
|||
// private void Approve(float unused)
|
|||
// {
|
|||
// try
|
|||
// { m_onResult?.Invoke(m_pendingConnection, Approval.OK);
|
|||
// }
|
|||
// finally
|
|||
// { Dispose();
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// public void Disapprove(Approval reason)
|
|||
// {
|
|||
// try
|
|||
// { m_onResult?.Invoke(m_pendingConnection, reason);
|
|||
// }
|
|||
// finally
|
|||
// { Dispose();
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// public void Dispose()
|
|||
// {
|
|||
// if (!m_hasDisposed)
|
|||
// {
|
|||
// Locator.Get.UpdateSlow.Unsubscribe(Approve);
|
|||
// m_hasDisposed = true;
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
// }
|
|
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Unity.Networking.Transport; |
|||
|
|||
namespace LobbyRelaySample.relay |
|||
{ |
|||
/// <summary>
|
|||
/// In addition to maintaining a heartbeat with the Relay server to keep it from timing out, the host player must pass network events
|
|||
/// from clients to all other clients, since they don't connect to each other.
|
|||
/// If you are using the Unity Networking Package, you can use their Relay instead of building your own packets.
|
|||
/// </summary>
|
|||
public class RelayUtpHost : RelayUtpClient, IReceiveMessages |
|||
{ |
|||
public override void Initialize(NetworkDriver networkDriver, List<NetworkConnection> connections, |
|||
LocalPlayer localUser, LocalLobby localLobby) |
|||
{ |
|||
base.Initialize(networkDriver, connections, localUser, localLobby); |
|||
m_hasSentInitialMessage = |
|||
true; // The host will be alone in the lobby at first, so they need not send any messages right away.
|
|||
Locator.Get.Messenger.Subscribe(this); |
|||
} |
|||
|
|||
protected override void Uninitialize() |
|||
{ |
|||
base.Uninitialize(); |
|||
Locator.Get.Messenger.Unsubscribe(this); |
|||
m_networkDriver.Dispose(); |
|||
} |
|||
|
|||
protected override void OnUpdate() |
|||
{ |
|||
if (!m_IsRelayConnected |
|||
) // If Relay was disconnected somehow, stop taking actions that will keep the allocation alive.
|
|||
return; |
|||
base.OnUpdate(); |
|||
UpdateConnections(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// When a new client connects, first determine if they are allowed to do so.
|
|||
/// If so, they need to be updated with the current state of everyone else.
|
|||
/// If not, they should be informed and rejected.
|
|||
/// </summary>
|
|||
void OnNewConnection(NetworkConnection conn, string id) |
|||
{ |
|||
new RelayPendingApproval(conn, NewConnectionApprovalResult, id); |
|||
} |
|||
|
|||
void NewConnectionApprovalResult(NetworkConnection conn, Approval result) |
|||
{ |
|||
WriteByte(m_networkDriver, conn, m_localUser.ID.Value, MsgType.PlayerApprovalState, (byte)result); |
|||
if (result == Approval.OK && conn.IsCreated) |
|||
{ |
|||
foreach (var user in m_localLobby.LocalPlayers) |
|||
ForceFullUserUpdate(m_networkDriver, conn, user.Value); |
|||
m_connections.Add(conn); |
|||
} |
|||
else |
|||
{ |
|||
conn.Disconnect(m_networkDriver); |
|||
} |
|||
} |
|||
|
|||
protected override bool CanProcessDataEventFor(NetworkConnection conn, MsgType type, string id) |
|||
{ |
|||
// Don't send through data from one client to everyone else if they haven't been approved yet. (They should also not be sending data if not approved, so this is a backup.)
|
|||
return id != m_localUser.ID.Value && |
|||
(m_localLobby.LocalPlayers.ContainsKey(id) && m_connections.Contains(conn) || |
|||
type == MsgType.NewPlayer); |
|||
} |
|||
|
|||
protected override void ProcessNetworkEventDataAdditional(NetworkConnection conn, MsgType msgType, string id) |
|||
{ |
|||
// Forward messages from clients to other clients.
|
|||
if (msgType == MsgType.PlayerName) |
|||
{ |
|||
string name = m_localLobby.LocalPlayers[id].DisplayName.Value; |
|||
foreach (NetworkConnection otherConn in m_connections) |
|||
{ |
|||
if (otherConn == conn) |
|||
continue; |
|||
WriteString(m_networkDriver, otherConn, id, msgType, name); |
|||
} |
|||
} |
|||
else if (msgType == MsgType.Emote || msgType == MsgType.ReadyState) |
|||
{ |
|||
byte value = msgType == MsgType.Emote |
|||
? (byte)m_localLobby.LocalPlayers[id].Emote.Value |
|||
: (byte)m_localLobby.LocalPlayers[id].UserStatus.Value; |
|||
foreach (NetworkConnection otherConn in m_connections) |
|||
{ |
|||
if (otherConn == conn) |
|||
continue; |
|||
WriteByte(m_networkDriver, otherConn, id, msgType, value); |
|||
} |
|||
} |
|||
else if (msgType == MsgType.NewPlayer) |
|||
OnNewConnection(conn, id); |
|||
else if (msgType == MsgType.PlayerDisconnect |
|||
) // Clients message the host when they intend to disconnect, or else the host ends up keeping the connection open.
|
|||
{ |
|||
UnityEngine.Debug.LogWarning("Disconnecting a client due to a disconnect message."); |
|||
conn.Disconnect(m_networkDriver); |
|||
m_connections.Remove(conn); |
|||
|
|||
#pragma warning disable 4014
|
|||
/*var queryCooldownMilliseconds = LobbyManager.Instance.GetRateLimit(LobbyManager.RequestType.Query) |
|||
.m_CoolDownMS; |
|||
// The user ready status lives in the lobby data, which won't update immediately, but we need to use it to identify if all remaining players have readied.
|
|||
// So, we'll wait two lobby update loops before we check remaining players to ensure the lobby has received the disconnect message.
|
|||
WaitAndCheckUsers(queryCooldownMilliseconds*2);*/ |
|||
#pragma warning restore 4014
|
|||
return; |
|||
} |
|||
|
|||
// If a client has changed state, check if this changes whether all players have readied.
|
|||
if (msgType == MsgType.ReadyState) |
|||
CheckIfAllUsersReady(); |
|||
} |
|||
|
|||
async Task WaitAndCheckUsers(int milliSeconds) |
|||
{ |
|||
await Task.Delay(milliSeconds); |
|||
CheckIfAllUsersReady(); |
|||
} |
|||
|
|||
protected override void ProcessDisconnectEvent(NetworkConnection conn, DataStreamReader strm) |
|||
{ |
|||
// When a disconnect from the host occurs, no additional action is required. This override just prevents the base behavior from occurring.
|
|||
// We rely on the PlayerDisconnect message instead of this disconnect message since this message might not arrive for a long time after the disconnect actually occurs.
|
|||
} |
|||
|
|||
public void OnUserStatusChanged() |
|||
{ |
|||
CheckIfAllUsersReady(); |
|||
} |
|||
|
|||
public void OnReceiveMessage(MessageType type, object msg) |
|||
{ |
|||
|
|||
if (type == MessageType.EndGame |
|||
) // This assumes that only the host will have the End Game button available; otherwise, clients need to be able to send this message, too.
|
|||
{ |
|||
foreach (NetworkConnection connection in m_connections) |
|||
WriteByte(m_networkDriver, connection, m_localUser.ID.Value, MsgType.EndInGame, 0); |
|||
} |
|||
} |
|||
|
|||
//TODO Move this to Host Check. Host pushes Start Signal to all users?
|
|||
void CheckIfAllUsersReady() |
|||
{ |
|||
bool haveAllReadied = true; |
|||
foreach (var user in m_localLobby.LocalPlayers) |
|||
{ |
|||
if (user.Value.UserStatus.Value != UserStatus.Ready) |
|||
{ |
|||
haveAllReadied = false; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (haveAllReadied && m_localLobby.LocalLobbyState.Value == LobbyState.Lobby |
|||
) // Need to notify both this client and all others that all players have readied.
|
|||
{ |
|||
Locator.Get.Messenger.OnReceiveMessage(MessageType.StartCountdown, null); |
|||
foreach (NetworkConnection connection in m_connections) |
|||
WriteByte(m_networkDriver, connection, m_localUser.ID.Value, MsgType.StartCountdown, 0); |
|||
} |
|||
else if (!haveAllReadied && m_localLobby.LocalLobbyState.Value == LobbyState.CountDown |
|||
) // Someone cancelled during the countdown, so abort the countdown.
|
|||
{ |
|||
Locator.Get.Messenger.OnReceiveMessage(MessageType.CancelCountdown, null); |
|||
foreach (NetworkConnection connection in m_connections) |
|||
WriteByte(m_networkDriver, connection, m_localUser.ID.Value, MsgType.CancelCountdown, 0); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// After the countdown, the host and all clients need to be alerted to sync up on game state, load assets, etc.
|
|||
/// </summary>
|
|||
public void SendInGameState() |
|||
{ |
|||
GameManager.Instance.ConfirmIngameState(); |
|||
foreach (NetworkConnection connection in m_connections) |
|||
WriteByte(m_networkDriver, connection, m_localUser.ID.Value, MsgType.ConfirmInGame, 0); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Clean out destroyed connections, and accept all new ones.
|
|||
/// </summary>
|
|||
void UpdateConnections() |
|||
{ |
|||
for (int c = m_connections.Count - 1; c >= 0; c--) |
|||
{ |
|||
if (!m_connections[c].IsCreated) |
|||
m_connections.RemoveAt(c); |
|||
} |
|||
|
|||
while (true) |
|||
{ |
|||
var conn = m_networkDriver |
|||
.Accept(); // Note that since we pumped the event queue earlier in Update, m_networkDriver has been updated already this frame.
|
|||
if (!conn.IsCreated |
|||
) // "Nothing more to accept" is signalled by returning an invalid connection from Accept.
|
|||
break; |
|||
|
|||
// Although the connection is created (i.e. Accepted), we still need to approve it, which will trigger when receiving the NewPlayer message from that client.
|
|||
} |
|||
} |
|||
|
|||
public override void Leave() |
|||
{ |
|||
foreach (NetworkConnection connection in m_connections) |
|||
connection.Disconnect( |
|||
m_networkDriver); // Note that Lobby won't receive the disconnect immediately, so its auto-disconnect takes 30-40s, if needed.
|
|||
m_connections.Clear(); |
|||
m_localLobby.RelayServer = null; |
|||
} |
|||
} |
|||
} |
|||
//
|
|||
// namespace LobbyRelaySample.relay
|
|||
// {
|
|||
// /// <summary>
|
|||
// /// In addition to maintaining a heartbeat with the Relay server to keep it from timing out, the host player must pass network events
|
|||
// /// from clients to all other clients, since they don't connect to each other.
|
|||
// /// If you are using the Unity Networking Package, you can use their Relay instead of building your own packets.
|
|||
// /// </summary>
|
|||
// public class RelayUtpHost : RelayUtpClient, IReceiveMessages
|
|||
// {
|
|||
// public override void Initialize(NetworkDriver networkDriver, List<NetworkConnection> connections,
|
|||
// LocalPlayer localUser, LocalLobby localLobby)
|
|||
// {
|
|||
// base.Initialize(networkDriver, connections, localUser, localLobby);
|
|||
// m_hasSentInitialMessage =
|
|||
// true; // The host will be alone in the lobby at first, so they need not send any messages right away.
|
|||
// Locator.Get.Messenger.Subscribe(this);
|
|||
// }
|
|||
//
|
|||
// protected override void Uninitialize()
|
|||
// {
|
|||
// base.Uninitialize();
|
|||
// Locator.Get.Messenger.Unsubscribe(this);
|
|||
// m_networkDriver.Dispose();
|
|||
// }
|
|||
//
|
|||
// protected override void OnUpdate()
|
|||
// {
|
|||
// if (!m_IsRelayConnected
|
|||
// ) // If Relay was disconnected somehow, stop taking actions that will keep the allocation alive.
|
|||
// return;
|
|||
// base.OnUpdate();
|
|||
// UpdateConnections();
|
|||
// }
|
|||
//
|
|||
// /// <summary>
|
|||
// /// When a new client connects, first determine if they are allowed to do so.
|
|||
// /// If so, they need to be updated with the current state of everyone else.
|
|||
// /// If not, they should be informed and rejected.
|
|||
// /// </summary>
|
|||
// void OnNewConnection(NetworkConnection conn, string id)
|
|||
// {
|
|||
// new RelayPendingApproval(conn, NewConnectionApprovalResult, id);
|
|||
// }
|
|||
//
|
|||
// void NewConnectionApprovalResult(NetworkConnection conn, Approval result)
|
|||
// {
|
|||
// WriteByte(m_networkDriver, conn, m_localUser.ID.Value, MsgType.PlayerApprovalState, (byte)result);
|
|||
// if (result == Approval.OK && conn.IsCreated)
|
|||
// {
|
|||
// foreach (var user in m_localLobby.LocalPlayers)
|
|||
// ForceFullUserUpdate(m_networkDriver, conn, user.Value);
|
|||
// m_connections.Add(conn);
|
|||
// }
|
|||
// else
|
|||
// {
|
|||
// conn.Disconnect(m_networkDriver);
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// protected override bool CanProcessDataEventFor(NetworkConnection conn, MsgType type, string id)
|
|||
// {
|
|||
// // Don't send through data from one client to everyone else if they haven't been approved yet. (They should also not be sending data if not approved, so this is a backup.)
|
|||
// return id != m_localUser.ID.Value &&
|
|||
// (m_localLobby.LocalPlayers.ContainsKey(id) && m_connections.Contains(conn) ||
|
|||
// type == MsgType.NewPlayer);
|
|||
// }
|
|||
//
|
|||
// protected override void ProcessNetworkEventDataAdditional(NetworkConnection conn, MsgType msgType, string id)
|
|||
// {
|
|||
// // Forward messages from clients to other clients.
|
|||
// if (msgType == MsgType.PlayerName)
|
|||
// {
|
|||
// string name = m_localLobby.LocalPlayers[id].DisplayName.Value;
|
|||
// foreach (NetworkConnection otherConn in m_connections)
|
|||
// {
|
|||
// if (otherConn == conn)
|
|||
// continue;
|
|||
// WriteString(m_networkDriver, otherConn, id, msgType, name);
|
|||
// }
|
|||
// }
|
|||
// else if (msgType == MsgType.Emote || msgType == MsgType.ReadyState)
|
|||
// {
|
|||
// byte value = msgType == MsgType.Emote
|
|||
// ? (byte)m_localLobby.LocalPlayers[id].Emote.Value
|
|||
// : (byte)m_localLobby.LocalPlayers[id].UserStatus.Value;
|
|||
// foreach (NetworkConnection otherConn in m_connections)
|
|||
// {
|
|||
// if (otherConn == conn)
|
|||
// continue;
|
|||
// WriteByte(m_networkDriver, otherConn, id, msgType, value);
|
|||
// }
|
|||
// }
|
|||
// else if (msgType == MsgType.NewPlayer)
|
|||
// OnNewConnection(conn, id);
|
|||
// else if (msgType == MsgType.PlayerDisconnect
|
|||
// ) // Clients message the host when they intend to disconnect, or else the host ends up keeping the connection open.
|
|||
// {
|
|||
// UnityEngine.Debug.LogWarning("Disconnecting a client due to a disconnect message.");
|
|||
// conn.Disconnect(m_networkDriver);
|
|||
// m_connections.Remove(conn);
|
|||
//
|
|||
// #pragma warning disable 4014
|
|||
// /*var queryCooldownMilliseconds = LobbyManager.Instance.GetRateLimit(LobbyManager.RequestType.Query)
|
|||
// .m_CoolDownMS;
|
|||
// // The user ready status lives in the lobby data, which won't update immediately, but we need to use it to identify if all remaining players have readied.
|
|||
// // So, we'll wait two lobby update loops before we check remaining players to ensure the lobby has received the disconnect message.
|
|||
// WaitAndCheckUsers(queryCooldownMilliseconds*2);*/
|
|||
// #pragma warning restore 4014
|
|||
// return;
|
|||
// }
|
|||
//
|
|||
// // If a client has changed state, check if this changes whether all players have readied.
|
|||
// if (msgType == MsgType.ReadyState)
|
|||
// CheckIfAllUsersReady();
|
|||
// }
|
|||
//
|
|||
// async Task WaitAndCheckUsers(int milliSeconds)
|
|||
// {
|
|||
// await Task.Delay(milliSeconds);
|
|||
// CheckIfAllUsersReady();
|
|||
// }
|
|||
//
|
|||
// protected override void ProcessDisconnectEvent(NetworkConnection conn, DataStreamReader strm)
|
|||
// {
|
|||
// // When a disconnect from the host occurs, no additional action is required. This override just prevents the base behavior from occurring.
|
|||
// // We rely on the PlayerDisconnect message instead of this disconnect message since this message might not arrive for a long time after the disconnect actually occurs.
|
|||
// }
|
|||
//
|
|||
// public void OnUserStatusChanged()
|
|||
// {
|
|||
// CheckIfAllUsersReady();
|
|||
// }
|
|||
//
|
|||
// public void OnReceiveMessage(MessageType type, object msg)
|
|||
// {
|
|||
//
|
|||
// if (type == MessageType.EndGame
|
|||
// ) // This assumes that only the host will have the End Game button available; otherwise, clients need to be able to send this message, too.
|
|||
// {
|
|||
// foreach (NetworkConnection connection in m_connections)
|
|||
// WriteByte(m_networkDriver, connection, m_localUser.ID.Value, MsgType.EndInGame, 0);
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// //TODO Move this to Host Check. Host pushes Start Signal to all users?
|
|||
// void CheckIfAllUsersReady()
|
|||
// {
|
|||
// bool haveAllReadied = true;
|
|||
// foreach (var user in m_localLobby.LocalPlayers)
|
|||
// {
|
|||
// if (user.Value.UserStatus.Value != UserStatus.Ready)
|
|||
// {
|
|||
// haveAllReadied = false;
|
|||
// break;
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// if (haveAllReadied && m_localLobby.LocalLobbyState.Value == LobbyState.Lobby
|
|||
// ) // Need to notify both this client and all others that all players have readied.
|
|||
// {
|
|||
// Locator.Get.Messenger.OnReceiveMessage(MessageType.StartCountdown, null);
|
|||
// foreach (NetworkConnection connection in m_connections)
|
|||
// WriteByte(m_networkDriver, connection, m_localUser.ID.Value, MsgType.StartCountdown, 0);
|
|||
// }
|
|||
// else if (!haveAllReadied && m_localLobby.LocalLobbyState.Value == LobbyState.CountDown
|
|||
// ) // Someone cancelled during the countdown, so abort the countdown.
|
|||
// {
|
|||
// Locator.Get.Messenger.OnReceiveMessage(MessageType.CancelCountdown, null);
|
|||
// foreach (NetworkConnection connection in m_connections)
|
|||
// WriteByte(m_networkDriver, connection, m_localUser.ID.Value, MsgType.CancelCountdown, 0);
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// /// <summary>
|
|||
// /// After the countdown, the host and all clients need to be alerted to sync up on game state, load assets, etc.
|
|||
// /// </summary>
|
|||
// public void SendInGameState()
|
|||
// {
|
|||
// GameManager.Instance.ConfirmIngameState();
|
|||
// foreach (NetworkConnection connection in m_connections)
|
|||
// WriteByte(m_networkDriver, connection, m_localUser.ID.Value, MsgType.ConfirmInGame, 0);
|
|||
// }
|
|||
//
|
|||
// /// <summary>
|
|||
// /// Clean out destroyed connections, and accept all new ones.
|
|||
// /// </summary>
|
|||
// void UpdateConnections()
|
|||
// {
|
|||
// for (int c = m_connections.Count - 1; c >= 0; c--)
|
|||
// {
|
|||
// if (!m_connections[c].IsCreated)
|
|||
// m_connections.RemoveAt(c);
|
|||
// }
|
|||
//
|
|||
// while (true)
|
|||
// {
|
|||
// var conn = m_networkDriver
|
|||
// .Accept(); // Note that since we pumped the event queue earlier in Update, m_networkDriver has been updated already this frame.
|
|||
// if (!conn.IsCreated
|
|||
// ) // "Nothing more to accept" is signalled by returning an invalid connection from Accept.
|
|||
// break;
|
|||
//
|
|||
// // Although the connection is created (i.e. Accepted), we still need to approve it, which will trigger when receiving the NewPlayer message from that client.
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// public override void Leave()
|
|||
// {
|
|||
// foreach (NetworkConnection connection in m_connections)
|
|||
// connection.Disconnect(
|
|||
// m_networkDriver); // Note that Lobby won't receive the disconnect immediately, so its auto-disconnect takes 30-40s, if needed.
|
|||
// m_connections.Clear();
|
|||
// m_localLobby.RelayServer = null;
|
|||
// }
|
|||
// }
|
|||
// }
|
|
|||
fileFormatVersion: 2 |
|||
guid: 9c0ea21ed066647a7a55a0c8959022ea |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue