Exemplo n.º 1
0
        public void Send(Instruction.OpCode type, Dictionary <string, InstructionParameter> parameters)
        {
            Packet p = new Packet(type, parameters);

            Shared.Log.Message("socket", "Sending " + p.GetOpCodes() + " to " + Host + ":" + Port.ToString());
            Connection.Sender.Send(Protocol.GetBytes(p));
        }
Exemplo n.º 2
0
        public ISocketCommand CreateCommand(Instruction.OpCode commandType)
        {
            switch (commandType)
            {
            case Instruction.OpCode.AUTH:
                return(new Commands.Auth());

            case Instruction.OpCode.AUTH_SPOTIFY:
                return(new Commands.AuthSpotify());

            case Instruction.OpCode.AUTH_DISCORD:
                return(new Commands.AuthDiscord());

            case Instruction.OpCode.AUTH_STREAMLABS:
                return(new Commands.AuthStreamlabs());

            case Instruction.OpCode.LOGIN:
                return(new Commands.Login());

            case Instruction.OpCode.INFO:
                return(new Shared.Services.Socket.Commands.Info());

            case Instruction.OpCode.PING:
                return(new Commands.Ping());
            }
            return(new Shared.Services.Socket.Commands.Default());
        }
Exemplo n.º 3
0
        public void SendToSession(Sender session, Instruction.OpCode type, Dictionary <string, string> arguments)
        {
            Dictionary <string, InstructionParameter> createdParameters = new Dictionary <string, InstructionParameter>();

            foreach (KeyValuePair <string, string> p in arguments)
            {
                createdParameters.Add(p.Key, new InstructionParameter(p.Value));
            }
            SendToSession(session, type, createdParameters);
        }
Exemplo n.º 4
0
        public void SendToAllSessions(Instruction.OpCode type, Dictionary <string, string> arguments, bool authenticatedUserRequired = true, string requiredScope = "")
        {
            Dictionary <string, InstructionParameter> createdParameters = new Dictionary <string, InstructionParameter>();

            foreach (KeyValuePair <string, string> p in arguments)
            {
                createdParameters.Add(p.Key, new InstructionParameter(p.Value));
            }
            SendToAllSessions(type, createdParameters, authenticatedUserRequired, requiredScope);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds an <see cref="T:JARVIS.Shared.Protocol.Instruction"/> to the packet.
        /// </summary>
        /// <param name="type">The Instruction's operation code.</param>
        /// <param name="parameters">The Instruction's parameters.</param>
        public void AddInstruction(Instruction.OpCode type, Dictionary <string, string> parameters)
        {
            Dictionary <string, InstructionParameter> convertedInstructions = new Dictionary <string, InstructionParameter>();

            foreach (KeyValuePair <string, string> p in parameters)
            {
                convertedInstructions.Add(p.Key, new InstructionParameter(p.Value));
            }
            Instructions.Add(new Instruction(type, convertedInstructions));
        }
Exemplo n.º 6
0
 public void SendToAllSessions(Instruction.OpCode type, Dictionary <string, InstructionParameter> arguments, bool authenticatedUserRequired = true, string requiredScope = "")
 {
     // Send to sessions
     foreach (Sender session in Server.Clients)
     {
         if (authenticatedUserRequired && AuthenticatedUsers.ContainsKey(session))
         {
             // Check scope
             if (AuthenticatedUsers[session].HasPemission(requiredScope))
             {
                 SendToSession(session, type, arguments);
             }
         }
         else
         {
             SendToSession(session, type, arguments);
         }
     }
 }
Exemplo n.º 7
0
 public void Send(Instruction.OpCode type, Dictionary <string, string> parameters) => Send(type, Instruction.CreateParametersDictionary(parameters));
Exemplo n.º 8
0
 public void Send(Instruction.OpCode type) => Send(type, new Dictionary <string, InstructionParameter>());
Exemplo n.º 9
0
 public void SendToSession(Sender session, Instruction.OpCode type, Dictionary <string, InstructionParameter> arguments)
 {
     Shared.Log.Message("socket", "Sending " + type.ToString() + " to " + session.RemoteEndPoint);
     session.Send(Protocol.GetBytes(new Packet(type, arguments)));
 }
Exemplo n.º 10
0
 public void SendToSession(Sender session, Instruction.OpCode type)
 {
     SendToSession(session, type, new Dictionary <string, InstructionParameter> {
     });
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:JARVIS.Shared.Protocol.Packet"/> class.
 /// </summary>
 /// <param name="operation">An Instruction's Operation.</param>
 /// <param name="parameters">An Instruction's Parameters.</param>
 public Packet(Instruction.OpCode operation, Dictionary <string, InstructionParameter> parameters)
 {
     AddInstruction(operation, parameters);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Adds an <see cref="T:JARVIS.Shared.Protocol.Instruction"/> to the packet.
 /// </summary>
 /// <param name="type">The Instruction's operation code.</param>
 /// <param name="parameters">The Instruction's parameters.</param>
 public void AddInstruction(Instruction.OpCode type, Dictionary <string, InstructionParameter> parameters)
 {
     Instructions.Add(new Instruction(type, parameters));
 }