Пример #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="iPacketID"></param>
 /// <param name="priority"></param>
 /// <param name="taskType"></param>
 /// <param name="onPacketReceive"></param>
 internal PacketHandler(ushort iPacketID, PacketPriority priority, TaskType taskType,
     PacketReceiveCallback onPacketReceive)
 {
     m_PacketID = iPacketID;
     m_PacketPriority = priority;
     m_OnReceive = onPacketReceive;
     m_TaskType = taskType;
 }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="iPacketID"></param>
        /// <param name="iLength"></param>
        /// <param name="bInGame"></param>
        /// <param name="onPacketReceive"></param>
        internal PacketHandler(long iPacketID, long iMinLength, PacketPriority priority, PacketReceiveCallback onPacketReceive)
        {
            m_PacketID = iPacketID;
            m_MinLength = iMinLength;
            m_PacketPriority = priority;
            m_OnReceive = onPacketReceive;

            CallTimes = 0;
            ElapsedTicks = 0;
        }
 public uint Send(FT_Session session, FT_DataBase data, PacketPriority priority, PacketReliability reliability, char orderingChannel, AddressOrGUID systemIdentifier) {
   uint ret = RakNetPINVOKE.FT_Node_Plugin_Send__SWIG_1(swigCPtr, FT_Session.getCPtr(session), FT_DataBase.getCPtr(data), (int)priority, (int)reliability, orderingChannel, AddressOrGUID.getCPtr(systemIdentifier));
   if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
        /// <summary>
        /// Sends a packet to the scene.
        /// </summary>
        /// <param name="route">A string containing the route on which the message should be sent.</param>
        /// <param name="writer">An action called.</param>
        /// <returns>A task completing when the transport takes</returns>
        public void SendPacket(string route, Action<Stream> writer, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY, PacketReliability reliability = PacketReliability.RELIABLE)
        {
            if (route == null)
            {
                DependencyResolver.GetComponent<ILogger>().Error("SendPacket failed: Tried to send a meesage on null route");
                throw new ArgumentNullException("no route selected");
            }
            if (writer == null)
            {
                DependencyResolver.GetComponent<ILogger>().Error("SendPacket failed: Tried to send message with a null writer");
                throw new ArgumentNullException("no writer given");
            }
            if (!this.Connected)
            {
                DependencyResolver.GetComponent<ILogger>().Error("SendPacket failed: Tried to send message without being connected");
                throw new InvalidOperationException("The scene must be connected to perform this operation.");
            }
            Route routeObj;
            if (!_remoteRoutesMap.TryGetValue(route, out routeObj))
            {
                DependencyResolver.GetComponent<ILogger>().Error("SendPacket failed: The route '{1}' doesn't exist on the scene.", route);
                throw new ArgumentException("The route " + route + " doesn't exist on the scene.");
            }

            _peer.SendToScene(this.Handle, routeObj.Handle, writer, priority, reliability);//.SendPacket(routeObj, writer, priority, reliability, channel);
        }
Пример #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="iPacketID"></param>
 /// <param name="priority"></param>
 /// <param name="onPacketReceive"></param>
 public void Register(ushort iPacketID, PacketPriority priority, PacketReceiveCallback onPacketReceive)
 {
     m_Handlers[iPacketID] = new PacketHandler(iPacketID, priority, onPacketReceive);
 }
Пример #6
0
 public override uint Send(BitStream bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, AddressOrGUID systemIdentifier, bool broadcast, uint forceReceiptNumber) {
   uint ret = RakNetPINVOKE.RakPeer_Send__SWIG_2(swigCPtr, BitStream.getCPtr(bitStream), (int)priority, (int)reliability, orderingChannel, AddressOrGUID.getCPtr(systemIdentifier), broadcast, forceReceiptNumber);
   if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 public override ReplicaReturnResult Serialize(ref bool sendTimestamp, BitStream outBitStream, uint lastSendTime, ref PacketPriority priority, ref PacketReliability reliability, uint currentTime, SystemAddress systemAddress, SWIGTYPE_p_unsigned_int flags)
 {
     return Listener.Serialize(ref sendTimestamp, outBitStream, lastSendTime, ref priority, ref reliability, currentTime, systemAddress, flags);
 }
        public Task <Packet> SendSystemRequest(IConnection peer, byte msgId, Action <Stream> writer, PacketPriority priority)
        {
            var tcs     = new TaskCompletionSource <Packet>();
            var request = ReserveRequestSlot(tcs);

            peer.SendSystem((byte)MessageIDTypes.ID_SYSTEM_REQUEST, bs =>
            {
                var bw = new BinaryWriter(bs);
                bw.Write(msgId);
                bw.Write(request.id);
                bw.Flush();
                writer(bs);
            }, priority);

            return(tcs.Task);
        }
Пример #9
0
 public virtual void CloseConnection(AddressOrGUID target, bool sendDisconnectionNotification, byte orderingChannel, PacketPriority disconnectionNotificationPriority) {
   RakNetPINVOKE.RakPeerInterface_CloseConnection__SWIG_0(swigCPtr, AddressOrGUID.getCPtr(target), sendDisconnectionNotification, orderingChannel, (int)disconnectionNotificationPriority);
   if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
 }
        /// <summary>
        /// Sends a remote procedure call using raw binary data as input and output.
        /// </summary>
        /// <param name="scene">The target scene. </param>
        /// <param name="route">The target route</param>
        /// <param name="writer">A writer method writing</param>
        /// <param name="priority">The priority level used to send the request.</param>
        /// <returns>An IObservable instance that provides return values for the request.</returns>
        public static IObservable <Packet <IScenePeer> > Rpc(this Scene scene, string route, Action <Stream> writer, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
        {
            var rpcService = scene.DependencyResolver.Resolve <Stormancer.Plugins.RpcClientPlugin.RpcService>();

            if (rpcService == null)
            {
                throw new NotSupportedException("RPC plugin not available.");
            }

            return(rpcService.Rpc(route, writer, priority));
        }
Пример #11
0
 public override void CloseConnection(AddressOrGUID target, bool sendDisconnectionNotification, byte orderingChannel, PacketPriority disconnectionNotificationPriority)
 {
     RakNetPINVOKE.RakPeer_CloseConnection__SWIG_0(swigCPtr, AddressOrGUID.getCPtr(target), sendDisconnectionNotification, orderingChannel, (int)disconnectionNotificationPriority);
     if (RakNetPINVOKE.SWIGPendingException.Pending)
     {
         throw RakNetPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Пример #12
0
 public override void Shutdown(uint blockDuration, byte orderingChannel, PacketPriority disconnectionNotificationPriority)
 {
     RakNetPINVOKE.RakPeer_Shutdown__SWIG_0(swigCPtr, blockDuration, orderingChannel, (int)disconnectionNotificationPriority);
 }
Пример #13
0
 public void SendToScene(byte sceneIndex, ushort route, Action <Stream> writer, PacketPriority priority, PacketReliability reliability)
 {
     Connection.SendToScene(sceneIndex, route, s =>
     {
         var stream = new OutputLogStream(s, _plugin._clientVM);
         writer(stream);
         stream.Log(sceneIndex, route);
     }, priority, reliability);
 }
        public ushort DownloadFromSubdirectory(FileList localFiles, string subdir, string outputSubdir, bool prependAppDirToOutputSubdir, SystemAddress host, FileListTransferCBInterface onFileCallback, PacketPriority _priority, char _orderingChannel, FileListProgress cb)
        {
            ushort ret = RakNetPINVOKE.DirectoryDeltaTransfer_DownloadFromSubdirectory__SWIG_1(swigCPtr, FileList.getCPtr(localFiles), subdir, outputSubdir, prependAppDirToOutputSubdir, SystemAddress.getCPtr(host), FileListTransferCBInterface.getCPtr(onFileCallback), (int)_priority, _orderingChannel, FileListProgress.getCPtr(cb));

            if (RakNetPINVOKE.SWIGPendingException.Pending)
            {
                throw RakNetPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
 public void SetUploadSendParameters(PacketPriority _priority, char _orderingChannel)
 {
     RakNetPINVOKE.DirectoryDeltaTransfer_SetUploadSendParameters(swigCPtr, (int)_priority, _orderingChannel);
 }
Пример #16
0
            /// <summary>
            /// Starts a RPC to the scene host.
            /// </summary>
            /// <param name="route">The remote route on which the message will be sent.</param>
            /// <param name="writer">The writer used to build the request's content.</param>
            /// <param name="priority">The priority used to send the request.</param>
            /// <returns>An IObservable instance returning the RPC responses.</returns>
            public IObservable<Packet<IScenePeer>> Rpc(string route, Action<Stream> writer, PacketPriority priority)
            {
                return Observable.Create<Packet<IScenePeer>>(
                    observer =>
                    {
                        var rr = _scene.RemoteRoutes.FirstOrDefault(r => r.Name == route);
                        if (rr == null)
                        {
							_scene.resolver.GetComponent<ILogger>().Error("Tried to send a message on a non existing route");
                            throw new ArgumentException("The target route does not exist on the remote host.");
                        }
                        string version;
                        if (!rr.Metadata.TryGetValue(RpcClientPlugin.PluginName, out version) || version != RpcClientPlugin.Version)
                        {
							_scene.resolver.GetComponent<ILogger>().Error("Target remote does not support RPC");
                            throw new InvalidOperationException("The target remote route does not support the plugin RPC version " + Version);
                        }

                        var rq = new Request { Observer = observer };
                        var id = this.ReserveId();
                        if (_pendingRequests.TryAdd(id, rq))
                        {

                            _scene.SendPacket(route, s =>
                            {
                                s.Write(BitConverter.GetBytes(id), 0, 2);
                                writer(s);
                            }, priority, PacketReliability.RELIABLE_ORDERED);
                        }

                        return () =>
                        {
                            _scene.SendPacket(CancellationRouteName, s =>
                            {
                                s.Write(BitConverter.GetBytes(id), 0, 2);
                            });
                            _pendingRequests.TryRemove(id, out rq);

                        };
                    });
            }
Пример #17
0
 public virtual uint Send(string data, int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, AddressOrGUID systemIdentifier, bool broadcast, uint forceReceiptNumber) {
   uint ret = RakNetPINVOKE.RakPeerInterface_Send__SWIG_0(swigCPtr, data, length, (int)priority, (int)reliability, orderingChannel, AddressOrGUID.getCPtr(systemIdentifier), broadcast, forceReceiptNumber);
   if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 /// <summary>
 /// Sends a remote procedure call with an object as input, expecting any number of answers.
 /// </summary>
 /// <typeparam name="TData">The type of data to send</typeparam>
 /// <typeparam name="TResponse">The expected type of the responses.</typeparam>
 /// <param name="scene">The target scene.</param>
 /// <param name="route">The target route.</param>
 /// <param name="data">The data object to send.</param>
 /// <param name="priority">The priority level used to send the request.</param>
 /// <returns>An IObservable instance that provides return values for the request.</returns>
 public static IObservable <TResponse> Rpc <TData, TResponse>(this Scene scene, string route, TData data, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
 {
     return(scene.Rpc(route, s => scene.Host.Serializer().Serialize(data, s), priority)
            .Select(p => p.ReadObject <TResponse>()));
 }
 public void SetUploadSendParameters(PacketPriority _priority, char _orderingChannel) {
   RakNetPINVOKE.DirectoryDeltaTransfer_SetUploadSendParameters(swigCPtr, (int)_priority, _orderingChannel);
 }
 /// <summary>
 /// Sends a remote procedure call with no input, expecting any number of answers.
 /// </summary>
 /// <typeparam name="TResponse">The expected type of the responses.</typeparam>
 /// <param name="scene">The target scene.</param>
 /// <param name="route">The target route.</param>
 /// <param name="priority">The priority level used to send the request.</param>
 /// <returns>An IObservable instance that provides return values for the request.</returns>
 public static IObservable <TResponse> Rpc <TResponse>(this Scene scene, string route, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
 {
     return(scene.Rpc(route, s => { }, priority)
            .Select(p => p.ReadObject <TResponse>()));
 }
Пример #21
0
 public static extern byte NETSND_ToAll(IntPtr instance_ptr, IntPtr bitstream_ptr, PacketPriority priority, PacketReliability reliablitity, int channel);
        /// <summary>
        /// Sends a remote procedure call using raw binary data as input, expecting no answer
        /// </summary>
        /// <param name="scene">The target scene. </param>
        /// <param name="route">The target route.</param>
        /// <param name="writer">A writer method writing the data to send.</param>
        /// <param name="priority">The priority level used to send the request.</param>
        /// <returns>A task representing the remote procedure.</returns>
        public static Task RpcVoid(this Scene scene, string route, Action <Stream> writer, CancellationToken cancellationToken, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
        {
            var observable = scene.Rpc(route, writer, priority).DefaultIfEmpty();

            return(observable.ToVoidTask(cancellationToken));
        }
Пример #23
0
 public override uint Send(string data, int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, AddressOrGUID systemIdentifier, bool broadcast) {
   uint ret = RakNetPINVOKE.RakPeer_Send__SWIG_1(swigCPtr, data, length, (int)priority, (int)reliability, orderingChannel, AddressOrGUID.getCPtr(systemIdentifier), broadcast);
   if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 public static Task RpcVoid <TData>(this Scene scene, string route, TData data, CancellationToken cancellationToken, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
 {
     return(scene.RpcVoid(route, stream => scene.Host.Serializer().Serialize(data, stream), cancellationToken, priority));
 }
        /// <summary>
        /// Sends a remote procedure call using raw binary data as input and output, expecting exactly one answer
        /// </summary>
        /// <param name="scene">The target scene. </param>
        /// <param name="route">The target route.</param>
        /// <param name="writer">A writer method writing the data to send.</param>
        /// <param name="priority">The priority level used to send the request.</param>
        /// <returns>A task representing the remote procedure, whose return value is the raw answer to the remote procedure call.</returns>
        public static Task <Packet <IScenePeer> > RpcTask(this Scene scene, string route, Action <Stream> writer, CancellationToken cancellationToken, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
        {
            var observable = scene.Rpc(route, writer, priority);

            return(observable.ToTask(cancellationToken));
        }
 public static Task <Packet <IScenePeer> > RpcTask(this Scene scene, string route, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
 {
     return(scene.RpcTask(route, CancellationToken.None, priority));
 }
Пример #27
0
 public void Send(FileList fileList, RakPeerInterface rakPeer, SystemAddress recipient, ushort setID, PacketPriority priority, char orderingChannel) {
   RakNetPINVOKE.FileListTransfer_Send__SWIG_2(swigCPtr, FileList.getCPtr(fileList), RakPeerInterface.getCPtr(rakPeer), SystemAddress.getCPtr(recipient), setID, (int)priority, orderingChannel);
   if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
 }
 /// <summary>
 /// Sends a remote procedure call with an object as input, expecting exactly one answer
 /// </summary>
 /// <typeparam name="TData">The type of data to send</typeparam>
 /// <typeparam name="TResponse">The expected type of the responses.</typeparam>
 /// <param name="scene">The target scene.</param>
 /// <param name="route">The target route.</param>
 /// <param name="data">The data object to send.</param>
 /// <param name="priority">The priority level used to send the request.</param>
 /// <returns>A task representing the remote procedure, whose return value is the deserialized value of the answer</returns>
 public static Task <TResponse> RpcTask <TData, TResponse>(this Scene scene, string route, TData data, CancellationToken cancellationToken, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
 {
     return(scene.RpcTask(route, s => scene.Host.Serializer().Serialize(data, s), cancellationToken, priority)
            .Then(result => result.ReadObject <TResponse>()));
 }
Пример #29
0
        public ReplicaReturnResult Serialize(ref bool sendTimestamp, BitStream outBitStream, uint lastSendTime, ref PacketPriority priority, ref PacketReliability reliability, uint currentTime, SystemAddress systemAddress, SWIGTYPE_p_unsigned_int flags)
        {
            if (lastSendTime == 0)
                Console.Write("First call to Player::Serialize for {0}:{1}\n", systemAddress.binaryAddress, systemAddress.port);

            outBitStream.Write(position);
            outBitStream.Write(health);
            return ReplicaReturnResult.REPLICA_PROCESSING_DONE;
        }
 public static Task <TResponse> RpcTask <TData, TResponse>(this Scene scene, string route, TData data, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
 {
     return(scene.RpcTask <TData, TResponse>(route, data, CancellationToken.None, priority));
 }
Пример #31
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="iPacketID"></param>
        /// <param name="priority"></param>
        /// <param name="onPacketReceive"></param>
        public void Register(ushort iPacketID, PacketPriority priority, PacketReceiveCallback onPacketReceive)
        {
            if (m_Handlers[iPacketID] != null)
            {
                Logs.Warn("Msgid {0} is replace.", iPacketID);
            }

            NetTaskProfile.GetNetTaskProfile(iPacketID);

            m_Handlers[iPacketID] = new PacketHandler(iPacketID, priority, onPacketReceive);
        }
 /// <summary>
 /// Sends a remote procedure call using raw binary data as input, expecting exactly one answer
 /// </summary>
 /// <typeparam name="TResponse">The expected type of the responses.</typeparam>
 /// <param name="scene">The target scene.</param>
 /// <param name="route">The target route.</param>
 /// <param name="writer">A writer method writing the data to send.</param>
 /// <param name="priority">The priority level used to send the request.</param>
 /// <returns>A task representing the remote procedure, whose return value is the deserialized value of the answer</returns>
 public static Task <TResponse> RpcTask <TResponse>(this Scene scene, string route, Action <Stream> writer, CancellationToken cancellationToken, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
 {
     return(scene.RpcTask(route, writer, cancellationToken, priority)
            .Then(result => result.ReadObject <TResponse>()));
 }
Пример #33
0
 public virtual void Shutdown(uint blockDuration, byte orderingChannel, PacketPriority disconnectionNotificationPriority) {
   RakNetPINVOKE.RakPeerInterface_Shutdown__SWIG_0(swigCPtr, blockDuration, orderingChannel, (int)disconnectionNotificationPriority);
 }
 public static Task <TResponse> RpcTask <TResponse>(this Scene scene, string route, Action <Stream> writer, PacketPriority priority = PacketPriority.MEDIUM_PRIORITY)
 {
     return(scene.RpcTask <TResponse>(route, writer, CancellationToken.None, priority));
 }
Пример #35
0
 public virtual uint Send(BitStream bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, AddressOrGUID systemIdentifier, bool broadcast) {
   uint ret = RakNetPINVOKE.RakPeerInterface_Send__SWIG_3(swigCPtr, BitStream.getCPtr(bitStream), (int)priority, (int)reliability, orderingChannel, AddressOrGUID.getCPtr(systemIdentifier), broadcast);
   if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
        public Task<Packet> SendSystemRequest(IConnection peer, byte msgId, Action<Stream> writer, PacketPriority priority)
        {
            var tcs = new TaskCompletionSource<Packet>();
            var request = ReserveRequestSlot(tcs);

            peer.SendSystem((byte)MessageIDTypes.ID_SYSTEM_REQUEST, bs =>
            {
                var bw = new BinaryWriter(bs);
                bw.Write(msgId);
                bw.Write(request.id);
                bw.Flush();
                writer(bs);

            }, priority);

            return tcs.Task;
        }
Пример #37
0
 public uint Send(byte[] inByteArray, int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, AddressOrGUID systemIdentifier, bool broadcast) {
   uint ret = RakNetPINVOKE.RakPeerInterface_Send__SWIG_4(swigCPtr, inByteArray, length, (int)priority, (int)reliability, orderingChannel, AddressOrGUID.getCPtr(systemIdentifier), broadcast);
   if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Пример #38
0
 public void Send(FileList fileList, RakPeerInterface rakPeer, SystemAddress recipient, ushort setID, PacketPriority priority, char orderingChannel, IncrementalReadInterface _incrementalReadInterface)
 {
     RakNetPINVOKE.FileListTransfer_Send__SWIG_1(swigCPtr, FileList.getCPtr(fileList), RakPeerInterface.getCPtr(rakPeer), SystemAddress.getCPtr(recipient), setID, (int)priority, orderingChannel, IncrementalReadInterface.getCPtr(_incrementalReadInterface));
     if (RakNetPINVOKE.SWIGPendingException.Pending)
     {
         throw RakNetPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public ushort DownloadFromSubdirectory(FileList localFiles, string subdir, string outputSubdir, bool prependAppDirToOutputSubdir, SystemAddress host, FileListTransferCBInterface onFileCallback, PacketPriority _priority, char _orderingChannel, FileListProgress cb) {
   ushort ret = RakNetPINVOKE.DirectoryDeltaTransfer_DownloadFromSubdirectory__SWIG_1(swigCPtr, FileList.getCPtr(localFiles), subdir, outputSubdir, prependAppDirToOutputSubdir, SystemAddress.getCPtr(host), FileListTransferCBInterface.getCPtr(onFileCallback), (int)_priority, _orderingChannel, FileListProgress.getCPtr(cb));
   if (RakNetPINVOKE.SWIGPendingException.Pending) throw RakNetPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
 public ReplicaReturnResult Serialize(ref bool sendTimestamp, BitStream outBitStream, uint lastSendTime, ref PacketPriority priority, ref PacketReliability reliability, uint currentTime, SystemAddress systemAddress, SWIGTYPE_p_unsigned_int flags)
 {
     return ReplicaReturnResult.REPLICA_CANCEL_PROCESS;
 }