maintain a local list of groups and remove groups upon leaving a room. Error checking for receiving messages for people that aren't in our room
parent
1b5be601ed
commit
0c0f4af669
|
|
@ -70,7 +70,17 @@ namespace VelNet
|
||||||
public List<NetworkObject> prefabs = new List<NetworkObject>();
|
public List<NetworkObject> prefabs = new List<NetworkObject>();
|
||||||
public NetworkObject[] sceneObjects;
|
public NetworkObject[] sceneObjects;
|
||||||
public List<string> deletedSceneObjects = new List<string>();
|
public List<string> deletedSceneObjects = new List<string>();
|
||||||
public readonly Dictionary<string, NetworkObject> objects = new Dictionary<string, NetworkObject>(); //maintains a list of all known objects on the server (ones that have ids)
|
|
||||||
|
/// <summary>
|
||||||
|
/// Maintains a list of all known objects on the server (ones that have ids)
|
||||||
|
/// </summary>
|
||||||
|
public readonly Dictionary<string, NetworkObject> objects = new Dictionary<string, NetworkObject>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Maintains a list of all known groups on the server
|
||||||
|
/// </summary>
|
||||||
|
public readonly Dictionary<string, List<int>> groups = new Dictionary<string, List<int>>();
|
||||||
|
|
||||||
private VelNetPlayer masterPlayer;
|
private VelNetPlayer masterPlayer;
|
||||||
public static VelNetPlayer LocalPlayer => instance.players.Where(p => p.Value.isLocal).Select(p => p.Value).FirstOrDefault();
|
public static VelNetPlayer LocalPlayer => instance.players.Where(p => p.Value.isLocal).Select(p => p.Value).FirstOrDefault();
|
||||||
public static bool InRoom => LocalPlayer != null && LocalPlayer.room != "-1" && LocalPlayer.room != "";
|
public static bool InRoom => LocalPlayer != null && LocalPlayer.room != "-1" && LocalPlayer.room != "";
|
||||||
|
|
@ -192,6 +202,14 @@ namespace VelNet
|
||||||
.Select(o => o.Key)
|
.Select(o => o.Key)
|
||||||
.ToList().ForEach(DeleteNetworkObject);
|
.ToList().ForEach(DeleteNetworkObject);
|
||||||
|
|
||||||
|
// empty all the groups
|
||||||
|
foreach (string group in instance.groups.Keys)
|
||||||
|
{
|
||||||
|
SetupMessageGroup(group, new List<int>());
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.groups.Clear();
|
||||||
|
|
||||||
Debug.Log("Left VelNet Room: " + oldRoom);
|
Debug.Log("Left VelNet Room: " + oldRoom);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -268,7 +286,15 @@ namespace VelNet
|
||||||
}
|
}
|
||||||
// generic message
|
// generic message
|
||||||
case 3:
|
case 3:
|
||||||
players[m.sender]?.HandleMessage(m);
|
if (players.ContainsKey(m.sender))
|
||||||
|
{
|
||||||
|
players[m.sender]?.HandleMessage(m);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("Received message from player that doesn't exist: " + m.text);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
// change master player (this should only happen when the first player joins or if the master player leaves)
|
// change master player (this should only happen when the first player joins or if the master player leaves)
|
||||||
case 4:
|
case 4:
|
||||||
|
|
@ -615,8 +641,13 @@ namespace VelNet
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// changes the designated group that sendto(4) will go to
|
/// changes the designated group that sendto(4) will go to
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SetupMessageGroup(string groupName, IEnumerable<int> userIds)
|
public static void SetupMessageGroup(string groupName, List<int> userIds)
|
||||||
{
|
{
|
||||||
|
if (userIds.Count > 0)
|
||||||
|
{
|
||||||
|
instance.groups[groupName] = userIds.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
SendNetworkMessage($"5:{groupName}:{string.Join(":", userIds)}");
|
SendNetworkMessage($"5:{groupName}:{string.Join(":", userIds)}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
comms = FindObjectOfType<DissonanceComms>();
|
comms = FindObjectOfType<DissonanceComms>();
|
||||||
microphones.AddOptions(new List<string>(Microphone.devices));
|
microphones.AddOptions(new List<string>(Microphone.devices));
|
||||||
velNetManager.MessageReceived += (m) =>
|
VelNetManager.MessageReceived += (m) =>
|
||||||
{
|
{
|
||||||
string s = m.type + ":" + m.sender + ":" + m.text;
|
string s = m.type + ":" + m.sender + ":" + m.text;
|
||||||
messageBuffer.Add(s);
|
messageBuffer.Add(s);
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ MonoBehaviour:
|
||||||
m_GameObject: {fileID: 6139051692386484099}
|
m_GameObject: {fileID: 6139051692386484099}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: c773e094326d413bb1bca7f91cbf7f8c, type: 3}
|
m_Script: {fileID: 11500000, guid: 068080cf74f24b74caef652efb5bcfdc, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
networkObject: {fileID: 9102273340480352682}
|
networkObject: {fileID: 9102273340480352682}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public class VelNetMan : MonoBehaviour
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
VelNetManager.instance.OnJoinedRoom += player =>
|
VelNetManager.OnJoinedRoom += player =>
|
||||||
{
|
{
|
||||||
VelNetManager.InstantiateNetworkObject(playerPrefab.name);
|
VelNetManager.InstantiateNetworkObject(playerPrefab.name);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ RectTransform:
|
||||||
- {fileID: 1557879931}
|
- {fileID: 1557879931}
|
||||||
- {fileID: 927188573}
|
- {fileID: 927188573}
|
||||||
m_Father: {fileID: 244561620}
|
m_Father: {fileID: 244561620}
|
||||||
m_RootOrder: 7
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
|
|
@ -596,14 +596,14 @@ RectTransform:
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1278634767}
|
|
||||||
- {fileID: 711524767}
|
|
||||||
- {fileID: 1894247853}
|
- {fileID: 1894247853}
|
||||||
- {fileID: 626742070}
|
- {fileID: 117638565}
|
||||||
- {fileID: 1760805525}
|
- {fileID: 1760805525}
|
||||||
|
- {fileID: 1278634767}
|
||||||
|
- {fileID: 626742070}
|
||||||
|
- {fileID: 711524767}
|
||||||
- {fileID: 945446556}
|
- {fileID: 945446556}
|
||||||
- {fileID: 1843597586}
|
- {fileID: 1843597586}
|
||||||
- {fileID: 117638565}
|
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 4
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
|
@ -870,7 +870,7 @@ RectTransform:
|
||||||
- {fileID: 2034439}
|
- {fileID: 2034439}
|
||||||
- {fileID: 1560686264}
|
- {fileID: 1560686264}
|
||||||
m_Father: {fileID: 244561620}
|
m_Father: {fileID: 244561620}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 4
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
|
|
@ -1041,7 +1041,7 @@ RectTransform:
|
||||||
- {fileID: 162005664}
|
- {fileID: 162005664}
|
||||||
- {fileID: 1484033256}
|
- {fileID: 1484033256}
|
||||||
m_Father: {fileID: 244561620}
|
m_Father: {fileID: 244561620}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 5
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
|
|
@ -1609,7 +1609,7 @@ RectTransform:
|
||||||
- {fileID: 1954037272}
|
- {fileID: 1954037272}
|
||||||
- {fileID: 1235343401}
|
- {fileID: 1235343401}
|
||||||
m_Father: {fileID: 244561620}
|
m_Father: {fileID: 244561620}
|
||||||
m_RootOrder: 5
|
m_RootOrder: 6
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
|
|
@ -1839,12 +1839,12 @@ MonoBehaviour:
|
||||||
udpConnected: 0
|
udpConnected: 0
|
||||||
userid: -1
|
userid: -1
|
||||||
room:
|
room:
|
||||||
|
connected: 0
|
||||||
prefabs:
|
prefabs:
|
||||||
- {fileID: 3951900052977689805, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
|
- {fileID: 3951900052977689805, guid: 6e4a023f70e01405e8b249a4488fe319, type: 3}
|
||||||
- {fileID: 9102273340480352682, guid: d4158ab9c4a204cdbba28d3273fc1fb3, type: 3}
|
- {fileID: 9102273340480352682, guid: d4158ab9c4a204cdbba28d3273fc1fb3, type: 3}
|
||||||
sceneObjects: []
|
sceneObjects: []
|
||||||
deletedSceneObjects: []
|
deletedSceneObjects: []
|
||||||
connected: 0
|
|
||||||
--- !u!1 &1154194181
|
--- !u!1 &1154194181
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -2082,7 +2082,7 @@ RectTransform:
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1295274441}
|
- {fileID: 1295274441}
|
||||||
m_Father: {fileID: 244561620}
|
m_Father: {fileID: 244561620}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 3
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
|
|
@ -2291,7 +2291,7 @@ MonoBehaviour:
|
||||||
m_GameObject: {fileID: 1434745018}
|
m_GameObject: {fileID: 1434745018}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 5d2009d8e264649749c0315d48765749, type: 3}
|
m_Script: {fileID: 11500000, guid: 0b249e3fdf4af5d4d9d36b9222998afa, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
dissonanceId:
|
dissonanceId:
|
||||||
|
|
@ -2350,7 +2350,7 @@ MonoBehaviour:
|
||||||
_metadataExpanded: 1
|
_metadataExpanded: 1
|
||||||
_activationModeExpanded: 1
|
_activationModeExpanded: 1
|
||||||
_tokensExpanded: 1
|
_tokensExpanded: 1
|
||||||
_ampExpanded: 0
|
_ampExpanded: 1
|
||||||
_activationFaderSettings:
|
_activationFaderSettings:
|
||||||
_volume: 1
|
_volume: 1
|
||||||
_fadeInTicks: 0
|
_fadeInTicks: 0
|
||||||
|
|
@ -2685,7 +2685,7 @@ RectTransform:
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 2118429759}
|
- {fileID: 2118429759}
|
||||||
m_Father: {fileID: 244561620}
|
m_Father: {fileID: 244561620}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
|
|
@ -2818,7 +2818,7 @@ RectTransform:
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1852007163}
|
- {fileID: 1852007163}
|
||||||
m_Father: {fileID: 244561620}
|
m_Father: {fileID: 244561620}
|
||||||
m_RootOrder: 6
|
m_RootOrder: 7
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
|
|
@ -3028,7 +3028,7 @@ RectTransform:
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 244561620}
|
m_Father: {fileID: 244561620}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 1}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "edu.uga.engr.vel.velnet",
|
"name": "edu.uga.engr.vel.velnet",
|
||||||
"displayName": "VelNet",
|
"displayName": "VelNet",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"unity": "2019.1",
|
"unity": "2019.1",
|
||||||
"description": "A custom networking library for Unity.",
|
"description": "A custom networking library for Unity.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue