Ejemplo n.º 1
0
 public ApplicationLayer(ApiTypes apiType, ISessionLayer sessionLayer, IFrameLayer frameLayer, ITransportLayer transportLayer)
 {
     ApiType        = apiType;
     SessionLayer   = sessionLayer;
     FrameLayer     = frameLayer;
     TransportLayer = transportLayer;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientInviteTransaction"/> class.
        /// </summary>
        /// <param name="transport">Transport layer used to send stuff.</param>
        /// <param name="request">Request that will be sent immidiately by the transaction.</param>
        public ClientInviteTransaction(ITransportLayer transport, IRequest request)
        {
            _transport = transport;
            if (request.Method != "INVITE")
            {
                throw new SipSharpException("Can only be used with invite transactions.");
            }

            State = TransactionState.Calling;
            _transport.Send(request);
            _request = request;

            // If an unreliable transport is being used, the client transaction MUST
            // start timer A with a value of T1. If a reliable transport is being used,
            // the client transaction SHOULD NOT start timer A
            if (!request.IsReliableProtocol)
            {
                _timerAValue = TransactionManager.T1;
                _timerA      = new Timer(OnRetransmission, null, _timerAValue, Timeout.Infinite);
            }
            else
            {
                _timerDValue = 0;
            }

            // For any transport, the client transaction MUST start timer B with a value of 64*T1 seconds
            _timerB = new Timer(OnTimeout, null, TransactionManager.T1 * 64, Timeout.Infinite);
            _timerD = new Timer(OnTerminate, null, _timerDValue, Timeout.Infinite);
        }
Ejemplo n.º 3
0
        public ServerNonInviteTransaction(ITransportLayer transport, IRequest request)
        {
            _timerJ = new Timer(OnTerminate);

            _transport = transport;
            _request   = request;
            State      = TransactionState.Trying;
        }
        public ServerNonInviteTransaction(ITransportLayer transport, IRequest request)
        {
            _timerJ = new Timer(OnTerminate);

            _transport = transport;
            _request = request;
            State = TransactionState.Trying;
        }
Ejemplo n.º 5
0
        public MyService(
            IEngine engine,
            ITransportLayer transportLayer)
        {
            _engine         = engine ?? throw new ArgumentNullException(nameof(engine));
            _transportLayer = transportLayer ?? throw new ArgumentNullException(nameof(transportLayer));

            _engine.OnRequestProcessed        += EngineOnRequestProcessed;
            _transportLayer.OnRequestReceived += TransportLayerOnRequestReceived;
        }
Ejemplo n.º 6
0
 static ServerServiceFactory()
 {
     ApplicationStack = (IServicesLayer)
                        (TransportLayer = new TransportLayer((IServicesLayer)
                                                             (LoggingLayer = new LoggingLayer(
                                                                  new NotificationLayer(
                                                                      new AuthorizationLayer(
                                                                          new ValidationLayer(
                                                                              new CachingLayer(
                                                                                  new DispatcherLayer(new ShopAdminService(), new BasketService(), new ShopService(), new UserService())))))))));
 }
Ejemplo n.º 7
0
        public NetworkRpcEndpoint(ITransportLayer transport, JsonRpcEndpoint.EndpointMode clientMode)
        {
            Transport = transport;
            Mode      = clientMode;

            RpcLayer = new JsonRpcEndpoint(transport.GetStream(), Mode);
            if (Mode.HasFlag(JsonRpcEndpoint.EndpointMode.Server))
            {
                RpcLayer.RequestPipeline.AddItemToStart(HandleRpcRequest);
            }
            if (Mode.HasFlag(JsonRpcEndpoint.EndpointMode.Client))
            {
                RpcLayer.ResponsePipeline.AddItemToStart(HandleRpcResponse);
            }
        }
Ejemplo n.º 8
0
        public SessionLayer(ITransportLayer <string> transport)
        {
            transport.Received.Subscribe(datagram =>
            {
                log.Debug($"datagram recv: tranposrt_id={datagram.ID} size={datagram.Data.Length}");

                int sessionID = 0;
                var idFound   = transportIDSessionIDTable.TryGetValue(datagram.ID, out sessionID);
                Debug.Assert(idFound == true, "session must be registered");

                Session session  = null;
                var sessionFound = TryGetSession(sessionID, out session);
                Debug.Assert(sessionFound == true, "session must be registered");

                OnNext(session, datagram.Data);
            });
        }
        /// <summary>
        /// save all message in the selected dump layer
        /// </summary>
        /// <param name="ServiceInstanceID"></param>
        /// <param name="MessagesID"></param>
        /// <param name="btArtifact"></param>
        private static void SaveMessages(Guid ServiceInstanceID, IEnumerable <Guid> MessagesID, BTArtifactLogic btArtifact)
        {
            LogHelper.WriteInfo(ResourceLogic.GetString(ResourceKeyName.MessageSaving));
            //retrieve the right layer
            ITransportLayer accessLayer = ConfigParameter.GettingTheRightLayer();

            foreach (Guid gu in MessagesID)
            {
                //retrieving the message
                String sMessage = btArtifact.GetMessageBodyByMessageId(gu, ServiceInstanceID);
                //save the message
                accessLayer.SendMessage(sMessage, gu);
                //updatecounter
                PerfCounterAsync.UpdateStatistic();
            }
            LogHelper.WriteInfo(ResourceLogic.GetString(ResourceKeyName.MessageSaved));
        }
Ejemplo n.º 10
0
        public ServerInviteTransaction(ITransportLayer transport, IRequest request)
        {
            _transport = transport;
            _request = request;
            State = TransactionState.Proceeding;
            _timerG = new Timer(OnRetransmit);
            _timerH = new Timer(OnTimeout);
            _timerI = new Timer(OnTerminated);
            _timerGValue = TransactionManager.T1;

            if (request.Method == "ACK")
                throw new InvalidOperationException("Expected any other type than ACK and INVITE");

            // The server transaction MUST generate a 100
            // (Trying) response unless it knows that the TU will generate a
            // provisional or final response within 200 ms, in which case it MAY
            // generate a 100 (Trying) response
            // Send(request.CreateResponse(StatusCode.Trying, "We are trying here..."));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientNonInviteTransaction"/> class.
        /// </summary>
        /// <param name="transport">Used to transport messages.</param>
        /// <param name="message">Request to process.</param>
        public ClientNonInviteTransaction(ITransportLayer transport, IMessage message)
        {
            _transport = transport;

            if (!(message is IRequest))
            {
                throw new SipSharpException("Client transaction can only be created with requests");
            }
            IRequest request = (Request) message;
            if (request.Method == "INVITE")
                throw new SipSharpException("Use ClientInviteTransaction for invite requests.");

            State = TransactionState.Trying;
            _timerF = new Timer(OnTimeout, null, TransactionManager.T1*64, Timeout.Infinite);
            if (!request.IsReliableProtocol)
            {
                _timerEValue = TransactionManager.T1;
                _timerE = new Timer(OnRetransmission, null, _timerEValue, Timeout.Infinite);
            }
            _transport.Send(request);
        }
Ejemplo n.º 12
0
        public ServerInviteTransaction(ITransportLayer transport, IRequest request)
        {
            _transport   = transport;
            _request     = request;
            State        = TransactionState.Proceeding;
            _timerG      = new Timer(OnRetransmit);
            _timerH      = new Timer(OnTimeout);
            _timerI      = new Timer(OnTerminated);
            _timerGValue = TransactionManager.T1;

            if (request.Method == "ACK")
            {
                throw new InvalidOperationException("Expected any other type than ACK and INVITE");
            }

            // The server transaction MUST generate a 100
            // (Trying) response unless it knows that the TU will generate a
            // provisional or final response within 200 ms, in which case it MAY
            // generate a 100 (Trying) response
            // Send(request.CreateResponse(StatusCode.Trying, "We are trying here..."));
        }
Ejemplo n.º 13
0
        public unsafe override void OnApplicationStart()
        {
            SteamClient.Init(823500);

            Features.Guard.GetSteamFriends();
            Features.Guard.GetLocalGuard();

#if DEBUG
            MelonModLogger.LogWarning("Debug build!");
#endif

            MelonModLogger.Log($"Multiplayer initialising with protocol version {PROTOCOL_VERSION}.");

            // Set up prefs
            ModPrefs.RegisterCategory("MPMod", "Multiplayer Settings");
            ModPrefs.RegisterPrefBool("MPMod", "BaldFord", false, "90% effective hair removal solution");

            // Initialise transport layer
            TransportLayer = new SteamTransportLayer();

            // Create the UI and cache the PlayerRep's model
            ui     = new MultiplayerUI();
            client = new Client(ui, TransportLayer);
            server = new Server(ui, TransportLayer);
            PlayerRep.LoadFord();

            // Configures if the PlayerRep's are showing or hiding certain parts
            PlayerRep.showBody = true;
            PlayerRep.showHair = ModPrefs.GetBool("MPMod", "BaldFord");

            // Initialize Discord's RichPresence
            RichPresence.Initialise(701895326600265879);
            client.SetupRP();

            #region Unused Code
            //PlayerHooks.OnPlayerGrabObject += PlayerHooks_OnPlayerGrabObject;
            //PlayerHooks.OnPlayerLetGoObject += PlayerHooks_OnPlayerLetGoObject;
            //BWUtil.InitialiseGunPrefabs();
            #endregion
        }
Ejemplo n.º 14
0
        public unsafe override void OnApplicationStart()
        {
            if (!SteamClient.IsValid)
            {
                SteamClient.Init(823500);
            }

#if DEBUG
            MelonModLogger.LogWarning("Debug build!");
#endif

            MelonLogger.Log($"Multiplayer initialising with protocol version {PROTOCOL_VERSION}.");

            // Set up prefs
            MelonPrefs.RegisterCategory("MPMod", "Multiplayer Settings");
            MelonPrefs.RegisterBool("MPMod", "BaldFord", false, "90% effective hair removal solution");

            // Initialise transport layer
            TransportLayer = new SteamTransportLayer();

            // Create the UI and cache the PlayerRep's model
            ui     = new MultiplayerUI();
            client = new Client(ui, TransportLayer);
            server = new Server(ui, TransportLayer);
            PlayerRep.LoadFord();

            // Configures if the PlayerRep's are showing or hiding certain parts
            PlayerRep.showBody = true;
            PlayerRep.showHair = MelonPrefs.GetBool("MPMod", "BaldFord");

            // Initialize Discord's RichPresence
            RichPresence.Initialise(701895326600265879);
            client.SetupRP();

            BWUtil.Hook();

            UnhollowerRuntimeLib.ClassInjector.RegisterTypeInIl2Cpp <SyncedObject>();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientNonInviteTransaction"/> class.
        /// </summary>
        /// <param name="transport">Used to transport messages.</param>
        /// <param name="message">Request to process.</param>
        public ClientNonInviteTransaction(ITransportLayer transport, IMessage message)
        {
            _transport = transport;

            if (!(message is IRequest))
            {
                throw new SipSharpException("Client transaction can only be created with requests");
            }
            IRequest request = (Request)message;

            if (request.Method == "INVITE")
            {
                throw new SipSharpException("Use ClientInviteTransaction for invite requests.");
            }

            State   = TransactionState.Trying;
            _timerF = new Timer(OnTimeout, null, TransactionManager.T1 * 64, Timeout.Infinite);
            if (!request.IsReliableProtocol)
            {
                _timerEValue = TransactionManager.T1;
                _timerE      = new Timer(OnRetransmission, null, _timerEValue, Timeout.Infinite);
            }
            _transport.Send(request);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClientInviteTransaction"/> class.
        /// </summary>
        /// <param name="transport">Transport layer used to send stuff.</param>
        /// <param name="request">Request that will be sent immidiately by the transaction.</param>
        public ClientInviteTransaction(ITransportLayer transport, IRequest request)
        {
            _transport = transport;
            if (request.Method != "INVITE")
                throw new SipSharpException("Can only be used with invite transactions.");

            State = TransactionState.Calling;
            _transport.Send(request);
            _request = request;

            // If an unreliable transport is being used, the client transaction MUST 
            // start timer A with a value of T1. If a reliable transport is being used, 
            // the client transaction SHOULD NOT start timer A 
            if (!request.IsReliableProtocol)
            {
                _timerAValue = TransactionManager.T1;
                _timerA = new Timer(OnRetransmission, null, _timerAValue, Timeout.Infinite);
            }
            else _timerDValue = 0;

            // For any transport, the client transaction MUST start timer B with a value of 64*T1 seconds 
            _timerB = new Timer(OnTimeout, null, TransactionManager.T1*64, Timeout.Infinite);
            _timerD = new Timer(OnTerminate, null, _timerDValue, Timeout.Infinite);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionManager"/> class.
 /// </summary>
 /// <param name="transport">Transport layer.</param>
 public TransactionManager(ITransportLayer transport)
 {
     _transport = transport;
 }
Ejemplo n.º 18
0
 public TextApplicationLayer(ISessionLayer sessionLayer, IFrameLayer frameLayer, ITransportLayer transportLayer)
     : base(ApiTypes.Text, sessionLayer, frameLayer, transportLayer)
 {
 }
Ejemplo n.º 19
0
 public NetworkRpcClient(ITransportLayer transport) : base(transport, JsonRpcEndpoint.EndpointMode.Client)
 {
 }
Ejemplo n.º 20
0
 public NetworkRpcService(ITransportLayer transport) : base(transport, JsonRpcEndpoint.EndpointMode.Server)
 {
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionManager"/> class.
 /// </summary>
 /// <param name="transport">Transport layer.</param>
 public TransactionManager(ITransportLayer transport)
 {
     _transport = transport;
 }
Ejemplo n.º 22
0
 public XModemApplicationLayer(ISessionLayer sessionLayer, IFrameLayer frameLayer, ITransportLayer transportLayer) :
     base(ApiTypes.XModem, sessionLayer, frameLayer, transportLayer)
 {
 }
Ejemplo n.º 23
0
 public Server(MultiplayerUI ui, ITransportLayer transportLayer)
 {
     this.ui             = ui;
     this.transportLayer = transportLayer;
 }
Ejemplo n.º 24
0
 public Client(MultiplayerUI ui, ITransportLayer transportLayer)
 {
     this.ui             = ui;
     this.transportLayer = transportLayer;
 }
Ejemplo n.º 25
0
 public BasicApplicationLayer(ISessionLayer sessionLayer, IFrameLayer frameLayer, ITransportLayer transportLayer)
     : base(ApiTypes.Basic, sessionLayer, frameLayer, transportLayer)
 {
 }