@@ -18,6 +18,42 @@ public enum ConnectionStateType
18
18
Hosting
19
19
}
20
20
21
+ public enum ConnectStatus
22
+ {
23
+ Undefined ,
24
+ Success , //client successfully connected. This may also be a successful reconnect.
25
+ ServerFull , //can't join, server is already at capacity.
26
+ LoggedInAgain , //logged in on a separate client, causing this one to be kicked out.
27
+ UserRequestedDisconnect , //Intentional Disconnect triggered by the user.
28
+ GenericDisconnect , //server disconnected, but no specific reason given.
29
+ Reconnecting , //client lost connection and is attempting to reconnect.
30
+ IncompatibleBuildType , //client build type is incompatible with server.
31
+ HostEndedSession , //host intentionally ended the session.
32
+ StartHostFailed , // server failed to bind
33
+ StartClientFailed // failed to connect to server and/or invalid network endpoint
34
+ }
35
+
36
+ public struct ReconnectMessage
37
+ {
38
+ public int CurrentAttempt ;
39
+ public int MaxAttempt ;
40
+
41
+ public ReconnectMessage ( int currentAttempt , int maxAttempt )
42
+ {
43
+ CurrentAttempt = currentAttempt ;
44
+ MaxAttempt = maxAttempt ;
45
+ }
46
+ }
47
+
48
+ [ Serializable ]
49
+ public class ConnectionPayload
50
+ {
51
+ public string playerId ;
52
+ public int clientScene = - 1 ;
53
+ public string playerName ;
54
+ public bool isDebug ;
55
+ }
56
+
21
57
public class ConnectionManager : MonoBehaviour
22
58
{
23
59
static readonly ConnectionStateType [ ] k_ConnectionStates = ( ConnectionStateType [ ] ) Enum . GetValues ( typeof ( ConnectionStateType ) ) ;
@@ -157,7 +193,7 @@ public static void SendServerToAllClientsSetDisconnectReason(ConnectStatus statu
157
193
{
158
194
var writer = new FastBufferWriter ( sizeof ( ConnectStatus ) , Allocator . Temp ) ;
159
195
writer . WriteValueSafe ( status ) ;
160
- NetworkManager . Singleton . CustomMessagingManager . SendNamedMessageToAll ( nameof ( ClientGameNetPortal . ReceiveServerToClientSetDisconnectReason_CustomMessage ) , writer ) ;
196
+ NetworkManager . Singleton . CustomMessagingManager . SendNamedMessageToAll ( nameof ( ReceiveServerToClientSetDisconnectReason_CustomMessage ) , writer ) ;
161
197
}
162
198
163
199
/// <summary>
@@ -169,7 +205,7 @@ public static void SendServerToClientSetDisconnectReason(ulong clientID, Connect
169
205
{
170
206
var writer = new FastBufferWriter ( sizeof ( ConnectStatus ) , Allocator . Temp ) ;
171
207
writer . WriteValueSafe ( status ) ;
172
- NetworkManager . Singleton . CustomMessagingManager . SendNamedMessage ( nameof ( ClientGameNetPortal . ReceiveServerToClientSetDisconnectReason_CustomMessage ) , clientID , writer ) ;
208
+ NetworkManager . Singleton . CustomMessagingManager . SendNamedMessage ( nameof ( ReceiveServerToClientSetDisconnectReason_CustomMessage ) , clientID , writer ) ;
173
209
}
174
210
}
175
211
}
0 commit comments