-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasisTestNetworkScene.cs
45 lines (42 loc) · 1.53 KB
/
BasisTestNetworkScene.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Basis.Scripts.BasisSdk;
using Basis.Scripts.BasisSdk.Players;
using Basis.Scripts.Networking;
using Basis.Scripts.Networking.NetworkedPlayer;
using LiteNetLib;
using UnityEngine;
public class BasisTestNetworkScene : MonoBehaviour
{
public byte[] SendingData;
public ushort[] Recipients;
public ushort MessageIndex;
public void Awake()
{
BasisNetworkManagement.OnLocalPlayerJoined += OnLocalPlayerJoined;
BasisNetworkManagement.OnRemotePlayerJoined += OnRemotePlayerJoined;
}
/// <summary>
/// this runs after a remote user connects and passes all there local checks and balances with the server
/// </summary>
/// <param name="player1"></param>
/// <param name="player2"></param>
private void OnRemotePlayerJoined(BasisNetworkedPlayer player1, BasisRemotePlayer player2)
{
}
/// <summary>
/// this is called once
/// level is loaded
/// network is connected
/// player is created
/// player is authenticated
/// </summary>
/// <param name="player1"></param>
/// <param name="player2"></param>
public void OnLocalPlayerJoined(BasisNetworkedPlayer player1, BasisLocalPlayer player2)
{
BasisScene.OnNetworkMessageReceived += OnNetworkMessageReceived;
BasisScene.OnNetworkMessageSend(MessageIndex, SendingData, DeliveryMethod.ReliableOrdered, Recipients);
}
private void OnNetworkMessageReceived(ushort PlayerID, ushort MessageIndex, byte[] buffer, DeliveryMethod Method = DeliveryMethod.ReliableOrdered)
{
}
}