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)); }
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()); }
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); }
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); }
/// <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)); }
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); } } }
public void Send(Instruction.OpCode type, Dictionary <string, string> parameters) => Send(type, Instruction.CreateParametersDictionary(parameters));
public void Send(Instruction.OpCode type) => Send(type, new Dictionary <string, InstructionParameter>());
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))); }
public void SendToSession(Sender session, Instruction.OpCode type) { SendToSession(session, type, new Dictionary <string, InstructionParameter> { }); }
/// <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); }
/// <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)); }