public void Listen() { DataEventManager.ListenSyncGameObject(this); ListISyncReceiver.Clear(); foreach (var receiver in GetComponents <ISyncReceiverByteArray>()) { ListISyncReceiver.Add(receiver); } }
public async UniTask SendByteArrayAsync(byte[] packet, Type type, Peer peer = null) { var typename = type.FullName; if (peer == null) { await DataEventManager.SendStreamAllPeer(InstanceID, DataEventPacket.Data, typename, packet); } else { await DataEventManager.SendStream(InstanceID, DataEventPacket.Data, typename, packet, SocketQosType.Unreliable, peer.ID); } }
private async UniTask SendRPC(string methodName, string typename, byte[] para, Peer peer = null) { if (peer == null) { await DataEventManager.SendStreamAllPeer(InstanceID, DataEventPacket.RPC, typename , Serializer.Serialize(new RPCRequest(methodName, para))); } else { await DataEventManager.SendStream(InstanceID, DataEventPacket.RPC, typename , Serializer.Serialize(new RPCRequest(methodName, para)) , SocketQosType.Unreliable, peer.ID); } }
public string Instance(string peerid, string id = "") { InstancePeerid = peerid; if (id == "") { InstanceID = Random.Range(int.MinValue, int.MaxValue).ToString(); } else { InstanceID = id; } Listen(); DataEventManager.ListenSyncGameObject(this); OnInstantiated(); return(InstanceID); }