예제 #1
0
 public void Listen()
 {
     DataEventManager.ListenSyncGameObject(this);
     ListISyncReceiver.Clear();
     foreach (var receiver in GetComponents <ISyncReceiverByteArray>())
     {
         ListISyncReceiver.Add(receiver);
     }
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
 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);
     }
 }
예제 #4
0
        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);
        }