fixes for mouse dragger, visualization for audio range, added some more callbacks to velnetmanager, added color syncing extension, take ownership of synced textbox, fix for deleting all scene objects
parent
dc61c63563
commit
682c470d46
|
|
@ -8,6 +8,8 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
public static class BinaryWriterExtensions
|
public static class BinaryWriterExtensions
|
||||||
{
|
{
|
||||||
|
#region Writers
|
||||||
|
|
||||||
public static void Write(this BinaryWriter writer, Vector3 v)
|
public static void Write(this BinaryWriter writer, Vector3 v)
|
||||||
{
|
{
|
||||||
writer.Write(v.x);
|
writer.Write(v.x);
|
||||||
|
|
@ -23,6 +25,18 @@ namespace VelNet
|
||||||
writer.Write(q.w);
|
writer.Write(q.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Write(this BinaryWriter writer, Color c)
|
||||||
|
{
|
||||||
|
writer.Write(c.r);
|
||||||
|
writer.Write(c.g);
|
||||||
|
writer.Write(c.b);
|
||||||
|
writer.Write(c.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Readers
|
||||||
|
|
||||||
public static Vector3 ReadVector3(this BinaryReader reader)
|
public static Vector3 ReadVector3(this BinaryReader reader)
|
||||||
{
|
{
|
||||||
return new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
return new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
||||||
|
|
@ -38,6 +52,19 @@ namespace VelNet
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Color ReadColor(this BinaryReader reader)
|
||||||
|
{
|
||||||
|
return new Color(
|
||||||
|
reader.ReadSingle(),
|
||||||
|
reader.ReadSingle(),
|
||||||
|
reader.ReadSingle(),
|
||||||
|
reader.ReadSingle()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compresses the list of bools into bytes using a bitmask
|
/// Compresses the list of bools into bytes using a bitmask
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -88,6 +115,5 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
return (b & (1 << index)) != 0;
|
return (b & (1 << index)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
|
@ -8,8 +7,6 @@ using System.Threading;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace VelNet
|
namespace VelNet
|
||||||
|
|
@ -42,10 +39,11 @@ namespace VelNet
|
||||||
private Thread clientReceiveThread;
|
private Thread clientReceiveThread;
|
||||||
private Thread clientReceiveThreadUDP;
|
private Thread clientReceiveThreadUDP;
|
||||||
public int userid = -1;
|
public int userid = -1;
|
||||||
private int messagesReceived = 0;
|
|
||||||
|
|
||||||
public readonly Dictionary<int, VelNetPlayer> players = new Dictionary<int, VelNetPlayer>();
|
public readonly Dictionary<int, VelNetPlayer> players = new Dictionary<int, VelNetPlayer>();
|
||||||
|
|
||||||
|
#region Callbacks
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// We just joined a room
|
/// We just joined a room
|
||||||
/// string - the room name
|
/// string - the room name
|
||||||
|
|
@ -69,8 +67,12 @@ namespace VelNet
|
||||||
public static Action<VelNetPlayer> OnPlayerLeft;
|
public static Action<VelNetPlayer> OnPlayerLeft;
|
||||||
|
|
||||||
public static Action OnConnectedToServer;
|
public static Action OnConnectedToServer;
|
||||||
public static Action LoggedIn;
|
public static Action OnLoggedIn;
|
||||||
public static Action<string[], int> RoomsReceived;
|
public static Action<RoomsMessage> RoomsReceived;
|
||||||
|
|
||||||
|
public static Action<Message> MessageReceived;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public bool connected;
|
public bool connected;
|
||||||
|
|
||||||
|
|
@ -107,38 +109,52 @@ namespace VelNet
|
||||||
|
|
||||||
public static bool IsConnected => instance != null && instance.connected && instance.udpConnected;
|
public static bool IsConnected => instance != null && instance.connected && instance.udpConnected;
|
||||||
|
|
||||||
|
|
||||||
//this is for sending udp packets
|
//this is for sending udp packets
|
||||||
static byte[] toSend = new byte[1024];
|
private static readonly byte[] toSend = new byte[1024];
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
public abstract class Message
|
public abstract class Message
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ListedRoom
|
public class ListedRoom
|
||||||
{
|
{
|
||||||
public string name;
|
public string name;
|
||||||
public int numUsers;
|
public int numUsers;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return "Room Name: " + name + "\tUsers: " + numUsers;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class LoginMessage : Message
|
public class LoginMessage : Message
|
||||||
{
|
{
|
||||||
public int userId;
|
public int userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RoomsMessage : Message
|
public class RoomsMessage : Message
|
||||||
{
|
{
|
||||||
public List<ListedRoom> rooms;
|
public List<ListedRoom> rooms;
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Join("\n", rooms);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class JoinMessage : Message
|
public class JoinMessage : Message
|
||||||
{
|
{
|
||||||
public int userId;
|
public int userId;
|
||||||
public string room;
|
public string room;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DataMessage : Message
|
public class DataMessage : Message
|
||||||
{
|
{
|
||||||
public int senderId;
|
public int senderId;
|
||||||
public byte[] data;
|
public byte[] data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ChangeMasterMessage : Message
|
public class ChangeMasterMessage : Message
|
||||||
{
|
{
|
||||||
public int masterId;
|
public int masterId;
|
||||||
|
|
@ -146,7 +162,6 @@ namespace VelNet
|
||||||
|
|
||||||
public class ConnectedMessage : Message
|
public class ConnectedMessage : Message
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly List<Message> receivedMessages = new List<Message>();
|
public readonly List<Message> receivedMessages = new List<Message>();
|
||||||
|
|
@ -180,6 +195,15 @@ namespace VelNet
|
||||||
//Debug.Log(messagesReceived++);
|
//Debug.Log(messagesReceived++);
|
||||||
receivedMessages.Add(m);
|
receivedMessages.Add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MessageReceived?.Invoke(m);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
|
@ -191,7 +215,7 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
switch (m)
|
switch (m)
|
||||||
{
|
{
|
||||||
case ConnectedMessage connected:
|
case ConnectedMessage msg:
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -202,16 +226,17 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
Debug.LogError(e);
|
Debug.LogError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LoginMessage lm:
|
case LoginMessage lm:
|
||||||
{
|
{
|
||||||
userid = lm.userId;
|
userid = lm.userId;
|
||||||
Debug.Log("joined server " + userid);
|
Debug.Log("Joined server " + userid);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LoggedIn?.Invoke();
|
OnLoggedIn?.Invoke();
|
||||||
}
|
}
|
||||||
// prevent errors in subscribers from breaking our code
|
// prevent errors in subscribers from breaking our code
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -221,17 +246,28 @@ namespace VelNet
|
||||||
|
|
||||||
//start the udp thread
|
//start the udp thread
|
||||||
clientReceiveThreadUDP = new Thread(ListenForDataUDP);
|
clientReceiveThreadUDP = new Thread(ListenForDataUDP);
|
||||||
clientReceiveThreadUDP.IsBackground = true;
|
|
||||||
clientReceiveThreadUDP.Start();
|
clientReceiveThreadUDP.Start();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RoomsMessage rm: {
|
case RoomsMessage rm:
|
||||||
Debug.Log("Got Rooms Message");
|
{
|
||||||
|
Debug.Log("Got Rooms Message:\n" + rm);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RoomsReceived?.Invoke(rm);
|
||||||
|
}
|
||||||
|
// prevent errors in subscribers from breaking our code
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case JoinMessage jm: {
|
case JoinMessage jm:
|
||||||
|
{
|
||||||
if (userid == jm.userId) //this is us
|
if (userid == jm.userId) //this is us
|
||||||
{
|
{
|
||||||
string oldRoom = LocalPlayer?.room;
|
string oldRoom = LocalPlayer?.room;
|
||||||
|
|
@ -260,7 +296,6 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
Debug.LogError(e);
|
Debug.LogError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// we just left a room
|
// we just left a room
|
||||||
else
|
else
|
||||||
|
|
@ -327,7 +362,18 @@ namespace VelNet
|
||||||
// TODO this may check for ownership in the future. We don't need ownership here
|
// TODO this may check for ownership in the future. We don't need ownership here
|
||||||
deleteObjects.ForEach(NetworkDestroy);
|
deleteObjects.ForEach(NetworkDestroy);
|
||||||
|
|
||||||
|
VelNetPlayer leftPlayer = players[jm.userId];
|
||||||
players.Remove(jm.userId);
|
players.Remove(jm.userId);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OnPlayerLeft?.Invoke(leftPlayer);
|
||||||
|
}
|
||||||
|
// prevent errors in subscribers from breaking our code
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -350,10 +396,11 @@ namespace VelNet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case DataMessage dm: {
|
case DataMessage dm:
|
||||||
|
{
|
||||||
if (players.ContainsKey(dm.senderId))
|
if (players.ContainsKey(dm.senderId))
|
||||||
{
|
{
|
||||||
players[dm.senderId]?.HandleMessage(dm); //todo
|
players[dm.senderId]?.HandleMessage(dm); //todo
|
||||||
|
|
@ -364,11 +411,9 @@ namespace VelNet
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
case ChangeMasterMessage cm: {
|
case ChangeMasterMessage cm:
|
||||||
|
{
|
||||||
if (masterPlayer == null)
|
if (masterPlayer == null)
|
||||||
{
|
{
|
||||||
masterPlayer = players[cm.masterId];
|
masterPlayer = players[cm.masterId];
|
||||||
|
|
@ -397,7 +442,6 @@ namespace VelNet
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -421,7 +465,6 @@ namespace VelNet
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
clientReceiveThread = new Thread(ListenForData);
|
clientReceiveThread = new Thread(ListenForData);
|
||||||
clientReceiveThread.IsBackground = true;
|
|
||||||
clientReceiveThread.Start();
|
clientReceiveThread.Start();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -432,10 +475,9 @@ namespace VelNet
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs in background clientReceiveThread; Listens for incomming data.
|
/// Runs in background clientReceiveThread; Listens for incoming data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
///
|
private static byte[] ReadExact(Stream stream, int N)
|
||||||
private byte[] ReadExact(NetworkStream stream, int N)
|
|
||||||
{
|
{
|
||||||
byte[] toReturn = new byte[N];
|
byte[] toReturn = new byte[N];
|
||||||
|
|
||||||
|
|
@ -446,20 +488,15 @@ namespace VelNet
|
||||||
numRead += stream.Read(toReturn, numRead, numLeft);
|
numRead += stream.Read(toReturn, numRead, numLeft);
|
||||||
numLeft = N - numRead;
|
numLeft = N - numRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetIntFromBytes(byte[] bytes)
|
private static int GetIntFromBytes(byte[] bytes)
|
||||||
{
|
{
|
||||||
if (BitConverter.IsLittleEndian)
|
return BitConverter.ToInt32(BitConverter.IsLittleEndian ? bytes.Reverse().ToArray() : bytes, 0);
|
||||||
{
|
|
||||||
return BitConverter.ToInt32(bytes.Reverse().ToArray(),0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return BitConverter.ToInt32(bytes, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListenForData()
|
private void ListenForData()
|
||||||
{
|
{
|
||||||
connected = true;
|
connected = true;
|
||||||
|
|
@ -476,7 +513,6 @@ namespace VelNet
|
||||||
//SendToGroup("close", Encoding.UTF8.GetBytes("HelloGroup"));
|
//SendToGroup("close", Encoding.UTF8.GetBytes("HelloGroup"));
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Get a stream object for reading
|
// Get a stream object for reading
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -491,7 +527,6 @@ namespace VelNet
|
||||||
}
|
}
|
||||||
else if (type == 1) //rooms
|
else if (type == 1) //rooms
|
||||||
{
|
{
|
||||||
|
|
||||||
RoomsMessage m = new RoomsMessage();
|
RoomsMessage m = new RoomsMessage();
|
||||||
m.rooms = new List<ListedRoom>();
|
m.rooms = new List<ListedRoom>();
|
||||||
int N = GetIntFromBytes(ReadExact(stream, 4)); //the size of the payload
|
int N = GetIntFromBytes(ReadExact(stream, 4)); //the size of the payload
|
||||||
|
|
@ -499,18 +534,19 @@ namespace VelNet
|
||||||
string roomMessage = Encoding.UTF8.GetString(utf8data);
|
string roomMessage = Encoding.UTF8.GetString(utf8data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string[] sections = roomMessage.Split(',');
|
string[] sections = roomMessage.Split(',');
|
||||||
foreach (string s in sections)
|
foreach (string s in sections)
|
||||||
{
|
{
|
||||||
string[] pieces = s.Split(':');
|
string[] pieces = s.Split(':');
|
||||||
if (pieces.Length == 2) {
|
if (pieces.Length == 2)
|
||||||
|
{
|
||||||
ListedRoom lr = new ListedRoom();
|
ListedRoom lr = new ListedRoom();
|
||||||
lr.name = pieces[0];
|
lr.name = pieces[0];
|
||||||
lr.numUsers = int.Parse(pieces[1]);
|
lr.numUsers = int.Parse(pieces[1]);
|
||||||
m.rooms.Add(lr);
|
m.rooms.Add(lr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddMessage(m);
|
AddMessage(m);
|
||||||
}
|
}
|
||||||
else if (type == 2) //joined
|
else if (type == 2) //joined
|
||||||
|
|
@ -521,7 +557,8 @@ namespace VelNet
|
||||||
byte[] utf8data = ReadExact(stream, N); //the room name, encoded as utf-8
|
byte[] utf8data = ReadExact(stream, N); //the room name, encoded as utf-8
|
||||||
m.room = Encoding.UTF8.GetString(utf8data);
|
m.room = Encoding.UTF8.GetString(utf8data);
|
||||||
AddMessage(m);
|
AddMessage(m);
|
||||||
}else if(type == 3) //data
|
}
|
||||||
|
else if (type == 3) //data
|
||||||
{
|
{
|
||||||
DataMessage m = new DataMessage();
|
DataMessage m = new DataMessage();
|
||||||
m.senderId = GetIntFromBytes(ReadExact(stream, 4));
|
m.senderId = GetIntFromBytes(ReadExact(stream, 4));
|
||||||
|
|
@ -532,7 +569,7 @@ namespace VelNet
|
||||||
else if (type == 4) //new master
|
else if (type == 4) //new master
|
||||||
{
|
{
|
||||||
ChangeMasterMessage m = new ChangeMasterMessage();
|
ChangeMasterMessage m = new ChangeMasterMessage();
|
||||||
m.masterId = (int)GetIntFromBytes(ReadExact(stream, 4)); //sender is the new master
|
m.masterId = GetIntFromBytes(ReadExact(stream, 4)); //sender is the new master
|
||||||
AddMessage(m);
|
AddMessage(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -584,10 +621,12 @@ namespace VelNet
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int numReceived = udpSocket.Receive(buffer);
|
int numReceived = udpSocket.Receive(buffer);
|
||||||
if (buffer[0] == 0)
|
switch (buffer[0])
|
||||||
{
|
{
|
||||||
|
case 0:
|
||||||
Debug.Log("UDP connected");
|
Debug.Log("UDP connected");
|
||||||
}else if (buffer[0] == 3)
|
break;
|
||||||
|
case 3:
|
||||||
{
|
{
|
||||||
DataMessage m = new DataMessage();
|
DataMessage m = new DataMessage();
|
||||||
//we should get the sender address
|
//we should get the sender address
|
||||||
|
|
@ -598,6 +637,8 @@ namespace VelNet
|
||||||
Array.Copy(buffer, 5, messageBytes, 0, messageBytes.Length);
|
Array.Copy(buffer, 5, messageBytes, 0, messageBytes.Length);
|
||||||
m.data = messageBytes;
|
m.data = messageBytes;
|
||||||
AddMessage(m);
|
AddMessage(m);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -634,7 +675,6 @@ namespace VelNet
|
||||||
NetworkStream stream = instance.socketConnection.GetStream();
|
NetworkStream stream = instance.socketConnection.GetStream();
|
||||||
if (stream.CanWrite)
|
if (stream.CanWrite)
|
||||||
{
|
{
|
||||||
|
|
||||||
stream.Write(message, 0, message.Length);
|
stream.Write(message, 0, message.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -652,9 +692,9 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
return BitConverter.GetBytes(n).Reverse().ToArray();
|
return BitConverter.GetBytes(n).Reverse().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Login(string username, string password)
|
public static void Login(string username, string password)
|
||||||
{
|
{
|
||||||
|
|
||||||
MemoryStream stream = new MemoryStream();
|
MemoryStream stream = new MemoryStream();
|
||||||
BinaryWriter writer = new BinaryWriter(stream);
|
BinaryWriter writer = new BinaryWriter(stream);
|
||||||
|
|
||||||
|
|
@ -667,14 +707,11 @@ namespace VelNet
|
||||||
writer.Write(pB);
|
writer.Write(pB);
|
||||||
|
|
||||||
SendTcpMessage(stream.ToArray());
|
SendTcpMessage(stream.ToArray());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetRooms()
|
public static void GetRooms()
|
||||||
{
|
{
|
||||||
|
SendTcpMessage(new byte[] { 1 }); //very simple message
|
||||||
SendTcpMessage(new byte[1] { 1 }); //very simple message
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -691,14 +728,9 @@ namespace VelNet
|
||||||
writer.Write((byte)R.Length);
|
writer.Write((byte)R.Length);
|
||||||
writer.Write(R);
|
writer.Write(R);
|
||||||
SendTcpMessage(stream.ToArray());
|
SendTcpMessage(stream.ToArray());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Leaves a room if we're in one
|
/// Leaves a room if we're in one
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -785,6 +817,7 @@ namespace VelNet
|
||||||
{
|
{
|
||||||
writer.Write(get_be_bytes(client_ids[i]));
|
writer.Write(get_be_bytes(client_ids[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
SendTcpMessage(stream.ToArray());
|
SendTcpMessage(stream.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -805,6 +838,7 @@ namespace VelNet
|
||||||
Debug.LogError("Can't instantiate object. Obj with that network ID was already instantiated.", instance.objects[networkId]);
|
Debug.LogError("Can't instantiate object. Obj with that network ID was already instantiated.", instance.objects[networkId]);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkObject newObject = Instantiate(prefab);
|
NetworkObject newObject = Instantiate(prefab);
|
||||||
newObject.networkId = networkId;
|
newObject.networkId = networkId;
|
||||||
newObject.prefabName = prefabName;
|
newObject.prefabName = prefabName;
|
||||||
|
|
@ -842,6 +876,7 @@ namespace VelNet
|
||||||
instance.objects.Remove(networkId);
|
instance.objects.Remove(networkId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.isSceneObject)
|
if (obj.isSceneObject)
|
||||||
{
|
{
|
||||||
instance.deletedSceneObjects.Add(networkId);
|
instance.deletedSceneObjects.Add(networkId);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "edu.uga.engr.vel.velnet",
|
"name": "edu.uga.engr.vel.velnet",
|
||||||
"displayName": "VelNet",
|
"displayName": "VelNet",
|
||||||
"version": "1.0.7",
|
"version": "1.0.8",
|
||||||
"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