/// <inheritdoc /> public void OnReceivedFrom(ClientConnection aClientConnection, byte[] aBuffer, int aBufferSize) { lock (receiveLock) { var buffer = Encoding.UTF8.GetString(aBuffer, 0, aBufferSize); lineReader.AddBuffer(buffer); // Извлекаем текст команды управления. var line = string.Empty; while ((line = lineReader.ReadLine()) != null) { if (state == State.LOGIN_PROMPTED) { // Проверка пароля. try { var password = line; if (login.Equals(password)) { Logger.Debug("Login is OK."); SendReply("\r\nLogin is OK, greetings from Audio Server 3.0\r\n"); state = State.LOGGED_IN; } else { Logger.Debug("Login failed."); SendReply("\r\nLogin is incorrect\r\n"); } } catch { } } else { var controlCommand = line; ProcessControlCommand(controlCommand); } } } }
protected override Task OnReceived(IRequest request, string connectionId, string data) { Broadcaster = this; // Broadcast data to all clients return Connection.Broadcast(data); }
public override void Process(ClientConnection conn, byte[] readBuffer, int length, int num) { if (conn.State == SlotState.ACCEPTED) { SlotManager.Schedule(conn, conn.DesiredQueue); return; } int whoAmI = conn.SlotIndex; if (Terraria.Netplay.Clients[whoAmI].State() == SlotState.ASSIGNING_SLOT) { Terraria.Netplay.Clients[whoAmI].SetState(SlotState.SENDING_WORLD); } var ctx = new HookContext() { Connection = conn, Player = conn.Player }; var args = new HookArgs.WorldRequestMessage() { SpawnX = Main.spawnTileX, SpawnY = Main.spawnTileY }; HookPoints.WorldRequestMessage.Invoke(ref ctx, ref args); //NewNetMessage.SendData(7, whoAmI); var msg = NewNetMessage.PrepareThreadInstance(); msg.WorldData(args.SpawnX, args.SpawnY); msg.Send(whoAmI); }
/// <summary> /// Add client instance to Collection /// by passing platenumber as key /// and client instance as value /// </summary> /// <param name="platenumber"></param> /// <param name="client"></param> public void Add(ClientConnection client) { /// check if (key) platenumber is not in the collection if (!this.collection.Contains(client)) /// add clientconnection to collection this.collection.Add(client); }
/// <summary> /// Конструктор. /// </summary> /// <param name="aClientConnection">Клиентское подключение.</param> /// <param name="bitReverce"></param> public CommandSession(ClientConnection aClientConnection, bool aBitReverce) : base(aClientConnection) { callback = null; GetClientConnection().SetCallback(this); bitReverce = aBitReverce; }
public static void AddClient(ClientConnection client) { lock (ClientsMonitor) { Clients.Add(client.Info.Username, client); } }
public static void RemoveClient(ClientConnection client) { lock (ClientsMonitor) { Clients.Remove(client.Info.Username); } }
public override void Process(ClientConnection conn, byte[] readBuffer, int length, int num) { //var data = Encoding.ASCII.GetString (readBuffer, num, length - 1); //var lines = data.Split ('\n'); //foreach (var line in lines) //{ // if (line == "tdcm1") // { // //player.HasClientMod = true; // ProgramLog.Log ("{0} is a TDCM protocol version 1 client.", conn.RemoteAddress); // } // else if (line == "tdsmcomp1") // { // conn.CompressionVersion = 1; // ProgramLog.Log ("{0} supports TDSM compression version 1.", conn.RemoteAddress); // } //} ReadString(readBuffer); var ctx = new HookContext { Connection = conn, }; var args = new HookArgs.DisconnectReceived { }; HookPoints.DisconnectReceived.Invoke(ref ctx, ref args); ctx.CheckForKick(); }
private void Disconnect(ClientConnection connection) { if (connection.Client.State != ClientState.Disconnected) { connection.Disconnect(); } }
public static void Dispatch(ClientConnection conn, byte[] readBuffer, int start, int length) { try { int num = start + 1; byte pkt = readBuffer[start]; if (conn.State == SlotState.SERVER_AUTH && pkt != 38) { conn.Kick("Incorrect password."); return; } if ((conn.State & SlotState.DISCONNECTING) == 0) { var handler = messageArray[pkt]; var state = conn.State; if (handler != null) { if ((state & handler.IgnoredStates) != 0) { //ProgramLog.Log("ignoring"); } else if ((state & handler.ValidStates) != 0) { //These guys are per thread, so we must ensure they are set or we will end up with strange issues (trust me...) if (Terraria.WorldGen.genRand == null) Terraria.WorldGen.genRand = new Random((new Random()).Next(Int32.MinValue, Int32.MaxValue)); if (Terraria.Main.rand == null) Terraria.Main.rand = new Random((new Random()).Next(Int32.MinValue, Int32.MaxValue)); handler.Reset(num); handler.Process(conn, readBuffer, length, num); } else { ProgramLog.Log("{0}: sent message {1} in state {2}.", conn.RemoteAddress, (pkt > 0 && pkt <= 76) ? (object)(Packet)pkt : pkt, conn.State); conn.Kick("Invalid operation in this state."); } } else { conn.Kick(String.Format("Message not understood ({0}).", pkt)); } } } catch (Exception e) { string pkt = "invalid packet"; if (readBuffer.Length > start) pkt = String.Format("packet {0}", (Packet)readBuffer[start]); ProgramLog.Log("Exception handling {0} of length {1} from {2}\n{3}", pkt, length, conn.RemoteAddress, e); conn.Kick("Server malfunction, please reconnect."); } }
//加入派生客户端链接类对象 public void AddClient(ClientConnection c) { if (m_clientStatck == null) { return; } m_clientStatck.Push(c); }
protected virtual void OnClientDisconnected(ClientConnection client) { lock (connectedClients) connectedClients.Remove(client); if (ClientDisconnected != null) ClientDisconnected(client); }
public MessageReceivedEventArgs(ClientConnection source, IMessage message, byte[] raw) { ClientConnection = source; Message = message; RawMessage = raw; IsError = false; ErrorMessage = string.Empty; }
/// <inheritdoc /> public void OnReceivedFrom(ClientConnection aClientConnection, byte[] aBuffer, int aBufferSize) { try { Logger.Info("Получена команда звукового сообщения"); Logger.Info("Разбор сообщения..."); Logger.Info("Бит-реверс: " + (bitReverce ? "ВКЛЮЧЕН" : "ВЫКЛЮЧЕН")); var message = new SoundCommand(); var size = Marshal.SizeOf(typeof (SoundCommand)); Logger.Info("Размер структуры звукового сообщения: " + size); var pHandle = Marshal.AllocHGlobal(size); Marshal.Copy(aBuffer, 0, pHandle, aBufferSize); Marshal.PtrToStructure(pHandle, message); Marshal.FreeHGlobal(pHandle); Logger.Info("Разбор сообщения завершен."); message.priority = ReverceBits(message.priority); Logger.Info("Приоритет: " + message.priority); message.channelCount = ReverceBits(message.channelCount); Logger.Info("Число каналов для объявления:" + message.channelCount); message.fileCount = ReverceBits(message.fileCount); Logger.Info("Число файлов для воспроизведения:" + message.fileCount); var channelsStr = string.Empty; for (var i = 0; i < message.channelCount && i < 15; ++i) { message.channels[i] = ReverceBits(message.channels[i]); channelsStr += message.channels[i] + " "; } Logger.Info("Список каналов для воспроизведения: " + channelsStr); var filesStr = Encoding.ASCII.GetString(message.files); var files = string.Empty; for (var i = 0; i < message.fileCount && i < 5; ++i) { files += "\"" + filesStr.Substring(i * 20, 20).Trim('\0') + "\" "; } Logger.Info("Список файлов для воспроизведения: " + files); if (message.channelCount > 0 && message.fileCount > 0 && message.channelCount <= 15 && message.fileCount <= 5) { var channels = new int[message.channelCount]; for (var i = 0; i < message.channelCount; ++i) { channels[i] = message.channels[i]; } var fileNames = new string[message.fileCount]; var messageFiles = Encoding.ASCII.GetString(message.files); for (var i = 0; i < message.fileCount; ++i) { fileNames[i] = messageFiles.Substring(i * 20, 20).Trim('\0'); } if (callback != null) { callback.OnPlaySound(this, channels, message.priority, fileNames); } } } catch (Exception ex) { Logger.Error("Ошибка при обработке сообщения: " + ex.Message); } }
public static void CleanRepositories(ClientConnection client) { //DisplayRepositoryState(); CleanClientRepository(client); // CleanConnectionRepository(client); //DisplayRepositoryState(); }
public override void Process(ClientConnection client, byte[] data) { using (var stream = new MemoryStream(data)) using (var reader = new BinaryReader(stream)) { string token = reader.ReadString(38, Encoding.ASCII).Replace("\0", ""); Core.Act(s => s.AuthProcessor.AuthProcess(client, token)); } }
protected void OnClientConnected(ClientConnection client) { client.Disconnected += OnClientDisconnected; client.DataReceived += OnClientDataReceived; lock (connectedClients) connectedClients.Add(client); if (ClientConnected != null) ClientConnected(client); }
public override void Process(ClientConnection client, byte[] data) { using (var stream = new MemoryStream(data)) using (var reader = new BinaryReader(stream)) { string token = Encoding.Unicode.GetString(reader.ReadBytes(2048)).Replace("\0", ""); if (!string.IsNullOrEmpty(token)) Core.Act(s => s.AuthProcessor.AuthProcess(client, token)); else Log.Error("Cannot process authorize, unreadable token"); } }
public override void Process(ClientConnection client, byte[] data) { var info = new CharacterData(); using (var stream = new MemoryStream(data)) using (var reader = new BinaryReader(stream)) { var profession = (ClassType)reader.ReadByte(); if (!Enum.IsDefined(typeof(ClassType), profession)) { Log.Error("Profession with hashcode {0} are not exist", profession); return; } var unk = reader.ReadByte(); var name = reader.ReadString(62).Replace("\0", ""); var zodiac = (Zodiac)reader.ReadByte(); if (!Enum.IsDefined(typeof(Zodiac), zodiac)) { Log.Error("Zodiac with hashcode {0} are not exist", zodiac); return; } var appearancePresets = reader.ReadBytes(10); var appearanceOptions = reader.ReadBytes(800); #if DEBUG Log.Debug( "Character creation report\n\tName: '{0}'\n\tUnk: {1}\n\tProfession: '{2}'\n\tZodiac: '{3}'", name, unk, profession, zodiac); #endif Log.Info(appearancePresets.FormatHex()); Log.Info(appearanceOptions.FormatHex()); info.AccountId = client.Account.Id; info.CharacterName = name; info.ClassType = profession; info.Zodiac = zodiac; info.AppearancePresets = appearancePresets; info.AppearanceOptions = appearanceOptions; Core.Act(s => s.LobbyProcessor.CreateCharacterProcess(client, info)); } }
public override void Process(ClientConnection client, byte[] data) { using (var stream = new MemoryStream(data)) { using (var reader = new BinaryReader(stream)) { var chatType = (ChatType) reader.ReadByte(); if (!Enum.IsDefined(typeof (ChatType), chatType)) return; var message = Encoding.ASCII.GetString(data.Skip(4).ToArray()).Replace("\0", ""); client.ActivePlayer.Action(Player.PlayerAction.Chat, chatType, message); } } }
//вызов метода после полной обработки поступившего запроса. отправляет ответ и закрывает соединение public async void OnHttpResponce(HTTPRequest responce, ClientConnection client) { if (responce == null) { client.socket.Close(); clientList.Remove(client); return; } foreach (String header in responce.headers) await client.socket.GetStream().WriteAsync(Encoding.UTF8.GetBytes(header), 0, header.Length); await client.socket.GetStream().WriteAsync(Encoding.UTF8.GetBytes("\r\n"), 0, 2); if(responce.content != null) await client.socket.GetStream().WriteAsync(responce.content, 0, responce.content.Length); await client.socket.GetStream().WriteAsync(Encoding.UTF8.GetBytes("\r\n"), 0, 2); client.socket.Close(); clientList.Remove(client); }
/// <summary> /// Конструктор. /// </summary> /// <param name="aClientConnection">Клиентское подключение.</param> public ControlSession(ClientConnection aClientConnection) : base(aClientConnection) { state = State.JUST_CREATED; callback = null; GetClientConnection().SetCallback(this); // Формируемый ответ. String reply = "Login:"; SendReply(reply); state = State.LOGIN_PROMPTED; channelInfoTimer = new Timer(); channelInfoTimer.Interval = 500; channelInfoTimer.Elapsed += ChannelInfoTimeEvent; channelInfoTimer.Start(); }
public void Run() { SynchronizationContext.SetSynchronizationContext(null); listeners.Add(new TcpTransportServerListener()); foreach (var listener in listeners) { if (listener.Bind(120)) { ITransportServerListener l = listener; var thread = new Thread(() => { SynchronizationContext.SetSynchronizationContext(null); l.RunLoop((t) => { var client = new ClientConnection(t, ZkLobbyServer); }); }); listenThreads.Add(thread); thread.Start(); thread.Priority = ThreadPriority.AboveNormal; } } }
/// <summary> /// Handle packet /// </summary> /// <param name="client">Client connection</param> /// <param name="packetBody">packet data</param> public static void Process(ClientConnection client, byte[] packetBody) { if (packetBody[0] == 1) //if crypto flag is 1, decrypt client.Session.Transform(ref packetBody); using (var stream = new MemoryStream(packetBody)) using (var reader = new BinaryReader(stream)) { var isCrypt = reader.ReadBoolean(); //need just read for move position, we decrypt before var sequence = reader.ReadInt16(); var opCode = reader.ReadInt16(); var body = reader.ReadBytes(packetBody.Length - 5); //without crypt flag, sequence and opCode length client.SequenceId = sequence; //install sequence id if (ClientFrames.ContainsKey(opCode)) //check, if packet exist ((APacketProcessor) Activator.CreateInstance(ClientFrames[opCode])).Process(client, body);//process packet else Console.WriteLine($"Unknown packet\nOpCode {opCode}\nData:\n {body.FormatHex()}"); //if packet not exist, we cannot proccess hem, just write log } }
/// <summary> /// Main loop for the thread that accepts new clients. /// </summary> static async void RunListenerLoop() { _listener = new TcpListener(IPAddress.Any, 14242); _listener.Start(); while (true) { if (_clients.Count >= _capacity) { await Task.Delay(100); } else { var socket = await _listener.AcceptTcpClientAsync(); var client = new ClientConnection(socket, _level); client.Run(); Console.WriteLine("New client connected from {0}.", socket.Client.RemoteEndPoint); _clients.Add(client); } } }
public void Send(ClientConnection client, bool isCrypted = true) { var body = WritedData(); //get body data from sended packet var packet = new byte[7 + body.Length]; //create buffer for packet var len = BitConverter.GetBytes((ushort)(body.Length + 7)); //get size for fully packet Buffer.BlockCopy(len, 0, packet, 0, 2); //copy packet size in buffer if (isCrypted) //if need crypt, set val packet[2] = 1; var opCode = PacketHandler.GetOpCode(GetType()); //get opcode from handler Buffer.BlockCopy(BitConverter.GetBytes(opCode), 0, packet, 5, 2); //copy opcode in buffer Buffer.BlockCopy(body, 0, packet, 7, body.Length); //copy packet body in buffer if (isCrypted) //packet ecnryption action { client.SequenceId++; //if we crypt packet, iterate sequence id var ch = BitConverter.GetBytes((short)client.SequenceId); //get sequence id bytes Buffer.BlockCopy(ch, 0, packet, 3, 2); //copy sequence id bytes in packet int templen = packet.Length - 2; //get len for crypted body (fully packet size without length) byte[] temp = new byte[templen]; //create temp for crypted body Buffer.BlockCopy(packet, 2, temp, 0, templen); //copy body datas in temp client.Session.Transform(ref temp); //encrypt datas in temp Buffer.BlockCopy(temp, 0, packet, 2, templen); //copy encrypted datas in packet } client.Socket.BeginSend(packet, 0, packet.Length, SocketFlags.None, null, null); //send packet datas to client }
protected override Task OnConnected(IRequest request, string connectionId) { Broadcaster = this; return Connection.Broadcast("Connection " + connectionId + " connected"); }
public void OnDataReceived(byte[] data, ClientConnection connection) { UserAccount userAccount = GetUser(connection); this.connector?.OnMessageReceived(Message.Parse(data), userAccount); }
public NodeConfigurationProcessor(ClientConnection client) : base(client) { }
public NP_CSMoveUnitPacket_0x0088(ClientConnection net) : base(01, 0x0088) { //1.0.1406 //NP_CSMoveUnitPacket_0x0088 // bc type time flags ix iy iz vel.x vel.y vel.z rot.x rot.y rot.z a.dm.x a.dm.y a.dm.z a.stance a.alertness a.flags //Recv: 2500 0001 8800 F52700 01 86C20100 04 322B7A F56D74 7DEB03 0000 0000 0000 00 00 2D 00 00 00 01 00 04 // 8006450 7630325 256893 // 2500 0001 8800 F52700 01 F27C0900 00 877B80 F00775 880803 0000 0000 C7FC 00 00 E6 00 00 00 02 00 00 //Recv: 2500 0001 8800 F52700 01 A82E1000 00 B56581 30C475 FF0E03 0000 0000 0000 00 00 F2 00 00 00 01 00 04 //Recv: 2500 0001 8800 F52700 01 B8C71100 00 C37681 B7C575 551003 0000 0000 0000 00 00 51 00 00 00 01 00 04 //движение //Recv: 2500 0001 8800 F52700 01 9F751900 02 0B3D82 650E76 62BD03 E107 77FA DC03 00 00 D9 00 7F 00 01 00 04 //появились на карте //Recv: 2500 0001 8800 F52700 01 85A80000 04 F5F679 0CD274 99BC03 0000 0000 0000 00 00 D0 00 00 00 01 00 14 // 7993077 7655948 244889 /* * - <packet id="0x008801" name="CSMoveUnitPacket"> * <part name="bc" type="b" size="3" /> //liveObjectId d3 from SCUnitStatePacket * <part name="type" type="c" id="1" /> * <part name="time" type="d" /> * <part name="flags" type="c" id="2" /> * - <bitwise_switch id="2"> * - <case id="0x10"> * <part name="scType" type="d" /> * <part name="phase" type="c" /> * </case> * <case id="default" /> * </bitwise_switch> * - <switch id="1"> * - <case id="1"> * <part name="ix" type="d3" /> * <part name="iy" type="d3" /> * <part name="iz" type="d3" /> * <part name="vel.x" type="h" /> * <part name="vel.y" type="h" /> * <part name="vel.z" type="h" /> * <part name="rot.x" type="C" /> * <part name="rot.y" type="C" /> * <part name="rot.z" type="C" /> * <part name="actor.deltaMovement.x" type="C" /> * <part name="actor.deltaMovement.y" type="C" /> * <part name="actor.deltaMovement.z" type="C" /> * <part name="actor.stance" type="C" /> * <part name="actor.alertness" type="C" /> * <part name="actor.flags" type="C" /> * - <bitwise_switch id="2"> * - <case id="0x80"> * <part name="actor.fallVel" type="h" /> * </case> * - <case id="0x20"> * <part name="actor.gcFlags" type="C" /> * <part name="actor.gcPartId" type="C" /> * <part name="ix" type="d3" /> * <part name="iy" type="d3" /> * <part name="iz" type="d3" /> * <part name="rot.x" type="C" /> * <part name="rot.y" type="C" /> * <part name="rot.z" type="C" /> * </case> * - <case id="0x60"> * <part name="actor.gcId" type="d" /> * </case> * - <case id="0x40"> * <part name="actor.climbData" type="d" /> * </case> * <case id="default" /> * </bitwise_switch> * </case> * - <case id="2"> * <part name="ix" type="d3" /> * <part name="iy" type="d3" /> * <part name="iz" type="d3" /> * <part name="vel.x" type="h" /> * <part name="vel.y" type="h" /> * <part name="vel.z" type="h" /> * <part name="rot.x" type="h" /> * <part name="rot.y" type="h" /> * <part name="rot.z" type="h" /> * <part name="vehicle.angVel[0]" type="f" /> * <part name="vehicle.angVel[1]" type="f" /> * <part name="vehicle.angVel[2]" type="f" /> * <part name="vehicle.steering" type="C" /> * <part name="vehicle.wheelVelCount" type="C" /> * </case> * - <case id="3"> * <part name="ix" type="d3" /> * <part name="iy" type="d3" /> * <part name="iz" type="d3" /> * <part name="vel.x" type="h" /> * <part name="vel.y" type="h" /> * <part name="vel.z" type="h" /> * <part name="rot.x" type="h" /> * <part name="rot.y" type="h" /> * <part name="rot.z" type="h" /> * <part name="ship.angVel[0]" type="f" /> * <part name="ship.angVel[1]" type="f" /> * <part name="ship.angVel[2]" type="f" /> * <part name="ship.steering" type="C" /> * <part name="ship.throttle" type="C" /> * <part name="ship.zoneId" type="h" /> * <part name="ship.stucked" type="C" /> * </case> * - <case id="4"> * <part name="shipRequest.throttle" type="C" /> * <part name="shipRequest.steering" type="C" /> * </case> * - <case id="5"> * <part name="ix" type="d3" /> * <part name="iy" type="d3" /> * <part name="iz" type="d3" /> * <part name="vel.x" type="h" /> * <part name="vel.y" type="h" /> * <part name="vel.z" type="h" /> * <part name="rot.x" type="h" /> * <part name="rot.y" type="h" /> * <part name="rot.z" type="h" /> * <part name="transfer.angVel[0]" type="f" /> * <part name="transfer.angVel[1]" type="f" /> * <part name="transfer.angVel[2]" type="f" /> * <part name="transfer.steering" type="d" /> * <part name="transfer.pathPointIndex" type="d" /> * <part name="transfer.speed" type="f" /> * <part name="transfer.reverse" type="C" /> * </case> * - <case id="default"> * <part name="ix" type="d3" /> * <part name="iy" type="d3" /> * <part name="iz" type="d3" /> * <part name="vel.x" type="h" /> * <part name="vel.y" type="h" /> * <part name="vel.z" type="h" /> * <part name="rot.x" type="h" /> * <part name="rot.y" type="h" /> * <part name="rot.z" type="h" /> * </case> * </switch> * </packet> */ }
public static void Handle_LoginSuccess(ClientConnection Client, PacketReader reader, byte last) { int unknow = reader.ReadLEInt16(); int clientVer = reader.ReadLEInt16(); int iplen = reader.ReadLEInt32(); string userip = reader.ReadStringSafe(iplen); int verlen = reader.ReadLEInt32(); string version = reader.ReadStringSafe(verlen); //Console.WriteLine("Client IP: " + userip); //Console.WriteLine("Client Version: " + version); Account User = Client.CurrentAccount; if (Conf.HashCheck) { if (!CheckHashIsValid(version)) { Log.Info("InCorrect hash. {0} : {1}", User.UserID, version); Client.SendAsync(new LoginError(User, 8, last)); return; } } bool logined = ClientConnection.CurrentAccounts.ToList().FindAll(players => players.Value.UserID == User.UserID).Count > 1; if (logined) { Log.Info("User [{0}] has already logged in!", User.UserID); Client.SendAsync(new LoginError(User, 0x6, last)); List <Account> objects = ClientConnection.CurrentAccounts.Values.ToList().FindAll(players => players.UserID == User.UserID); foreach (Account obj in objects) { if (obj.Session != User.Session) { obj.Connection.SendAsync(new DisconnectPacket(obj, 257, last)); } } return; } int onlinecount = ClientConnection.CurrentAccounts.Count; if (onlinecount > Conf.MaxUserCount) { Log.Error("User [{0}] can't login because server full!", User.UserID); Client.SendAsync(new LoginError(User, 0x7, last)); return; } if (CheckBlackList(User.UserID, out long startdate, out long enddate)) { Client.SendAsync(new LoginBlackList(User, startdate, enddate, last)); return; } Client.SendAsync(new NP_Byte(User, DBInit.Levels)); Client.SendAsync(new LoginUserInfo_0X02(User, last)); //op 0x02 //SendNoOpCode(StringToByteArray("02A800313DFFFF57640000E10C00000000000075030000000000000000000061AC0000FFFFFFFF0000000000000000CB781167B68B0600CB781167B68B0600CB781167B68B0600FFFFFFFFFFFFFFFFFFFF2836FFFFFFFF000000000000000000000000000000000000004F624C2667010000020023C3C0A801042C5E4878000000000100000000010000000000000000000000000000000020000000590200000000000000000000050000000400000000000000000000001414000000000000000000000000000000000002")); Client.SendAsync(new NP_Byte(User, DBInit.HackTools)); Client.SendAsync(new NP_Hex(User, "06000000000002")); Client.SendAsync(new NP_Hex(User, "070000000002")); Client.SendAsync(new NP_Hex(User, "130000000002")); Client.SendAsync(new NP_Byte(User, DBInit.GameServerSetting)); Client.SendAsync(new NP_Byte(User, DBInit.SmartChannelModeInfo)); //op 1297 Client.SendAsync(new NP_Byte(User, DBInit.SmartChannelScheduleInfo)); //op 1298 Client.SendAsync(new NP_Byte(User, DBInit.RoomKindPenaltyInfo)); //op 1301 Client.SendAsync(new NP_Hex(User, "FF4205000000000000000002")); Client.SendAsync(new NP_Hex(User, "FF88010100000002")); //xtrap?? //Client.SendAsync(new NP_Hex(User, "4201000000000000009744573A1B23AE0AA0122B0E8842434C621C9C4D232EDC72342AC06AC556E309A64AEC19990FF9220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006400000097003BB70030951A00200000ECFB87064EB3827C0000F1010030951A0030951A0000F101000052170000521700005C0834FC870641B8827C0020000000309501000000000000F1010030951A02")); Client.SendAsync(new NP_Hex(User, "FFF10500000000000000000000000002")); Client.SendAsync(new Myroom_CheckExistNewGift(User, last)); //new gift Client.SendAsync(new NP_Hex(User, "FF430601000000000000000000000000000000000000000000000000000002")); //SendNoOpCode(StringToByteArray("FF2D02872100005E8C0600C310000061080000BC0B0000160F000002")); //usp_IndividualRecordGetGame Client.SendAsync(new LoginUserIndividualRecordGameRecord_FF2D02(User, last)); //opcode 557 //SendNoOpCode(StringToByteArray("FF2E02000074530000000013000000000000000000000000000000000000000000000002")); //usp_IndividualRecordGetMiscellaneous Client.SendAsync(new LoginUserIndividualRecordMiscellaneous_FF2E02(User, last)); //opcode 558 MyRoomHandle.ExpiredItemCheck(User); Client.SendAsync(new NP_Hex(User, "FF2E050200000000000000000000000000000000000000000000000000000002")); //shu info? Client.SendAsync(new NP_Hex(User, "FFB8040000000002")); //usp_anubisExpeditionGetUserInfo Client.SendAsync(new NP_Hex(User, "6A000000000000000002")); getNickname(User); getUserCash(User); //SendNoOpCode(StringToByteArray("FFD2011800000000D8F7110000000000000000000100000015000000577269746520796F7572206661726D206E616D652E07000000706F706F424242C0F63AB612040000C0266DF93301000001000200000000000000000000000000000000000000000000000002")); Client.SendAsync(new LoginFarm_GetMyFarmInfo_FF1D02(User, last)); //opcode 466 Client.SendAsync(new NP_Hex(User, "FFB10400000000000000573A0000000000000100C0644C266701000002")); //time?? Client.SendAsync(new NP_Hex(User, "FF9B0400000000000000000002")); Client.SendAsync(new NP_Hex(User, "FFA3040104000000500E0300510E0300520E0300530E030002")); //onRecvQuestEventNotify? Client.SendAsync(new NP_Hex(User, "FFA40400000000000000000002")); //onRecvLobbyQuestUserInfo? Client.SendAsync(new NP_Hex(User, "FFAC0401040000000100000002000000030000000400000002")); //onRecvLobbyQuestEventNotify? if (!User.noNickName) { Client.SendAsync(new LoginNickName_0X20(User, last)); //opcode 32 } Client.SendAsync(new NP_Hex(User, "FF2E0508000000000000000000000004")); getUserItemAttr(User); Client.SendAsync(new MyroomGetUserItemAttr(User, last)); //鍊金能力 User.GetMyLevel(); }
public static void Handle_GetUserCash(ClientConnection Client, byte last) { //SendNoOpCodeString("FF7901000000000200000004"); Client.SendAsync(new LoginGetUserCash_0X179(Client.CurrentAccount, last)); }
public static void Handle_6E(ClientConnection Client, byte last) { Client.SendAsync(new Login_6E_0X6F(Client.CurrentAccount, last)); }
public ChangeNodeRequestHandler(Request request, ClientConnection clientConnection, IChangeNodeOperationsService changeNodeOperationsService) { this.request = (ChangeNodeRequest)request; this.clientConnection = clientConnection; this.changeNodeOperationsService = changeNodeOperationsService; }
/// <summary> /// Вызывается когда игрок присоеденился к комнате /// </summary> /// <param name="clientConnection"></param> public override void IncomingClient(ClientConnection clientConnection) { //Для начала оповестим нашего пользователя об успешном входе в комнату SendRoomEnterSusses(clientConnection); }
public static void Handle_FF2E0505(ClientConnection Client, byte last) { //SendNoOpCodeString("FF2E050500000000000000000000000000000040"); Client.SendAsync(new Login_FF2E0505(Client.CurrentAccount, last)); }
private static void PClient_Disconnected(object sender, ClientConnection pClient) { pClient.Disconnected -= PClient_Disconnected; _lstClients.Remove(pClient); }
public YouAreOwnerModifier(ClientConnection connection, IPacket packetOriginal, Release releaseFrom, Release releaseTarget) : base(connection, packetOriginal, releaseFrom, releaseTarget) { }
private static void OnConnectionEvent(object parameter, ClientConnection connection, ClientConnectionEvent eventType) { SmprMonitoringService.Log("connection event " + eventType.ToString() + " " + connection.RemoteEndpoint); }
public static void Handle_GetCommunityAgentServer(ClientConnection Client, byte last) { Client.SendAsync(new GetCommunityAgentServer_0X74(Client.CurrentAccount, last)); }
public override void Process(ClientConnection conn, byte[] readBuffer, int length, int pos) { var slot = conn.SlotIndex; if (slot >= 0) Process(slot, readBuffer, length, pos); else ProgramLog.Log("Attempt to process packet {0} before slot assignment.", GetPacket()); }
public ClientRegistrationProcessor(ClientConnection agent) : base(agent) { }
private void RegisterListenerOnConnection(ListenerRegistration listenerRegistration, ClientConnection connection) { //This method should only be called from registrationExecutor Debug.Assert(Thread.CurrentThread.Name != null && Thread.CurrentThread.Name.Contains("eventRegistration")); if (listenerRegistration.ConnectionRegistrations.ContainsKey(connection)) { return; } var future = ((ClientInvocationService)_client.GetInvocationService()).InvokeListenerOnConnection( listenerRegistration.RegistrationRequest, listenerRegistration.EventHandler, connection); IClientMessage clientMessage; try { clientMessage = ThreadUtil.GetResult(future); } catch (Exception e) { throw ExceptionUtil.Rethrow(e); } var serverRegistrationId = listenerRegistration.DecodeRegisterResponse(clientMessage); var correlationId = listenerRegistration.RegistrationRequest.GetCorrelationId(); var registration = new EventRegistration(serverRegistrationId, correlationId, connection); Debug.Assert(listenerRegistration.ConnectionRegistrations != null, "registrationMap should be created!"); listenerRegistration.ConnectionRegistrations[connection] = registration; }
public GetCatalogIndexModifier(ClientConnection connection, IPacket packetOriginal, Release releaseFrom, Release releaseTarget) : base(connection, packetOriginal, releaseFrom, releaseTarget) { }
public static void Handle_GetNickName(ClientConnection Client, PacketReader reader, byte last) { Client.SendAsync(new LoginGetNickName_0X1C(Client.CurrentAccount, last)); }
public async void SendEncryptedKeysNoticeAsync(byte[] encryptedData, byte[] encryptedSymmetricKey, ClientConnection responseConnection, ClientConnection requestorConnection, byte[] publicKey) { try { EncryptedKeysNotice encryptedKeysNotice = new EncryptedKeysNotice( responseConnection.CurrentToken.OSName, responseConnection.CurrentToken.AppName, responseConnection.CurrentToken.DeviceName, encryptedSymmetricKey, encryptedData, publicKey); await SendNoticeToClientAsync(requestorConnection, encryptedKeysNotice).ConfigureAwait(false); } catch (Exception ex) { Logger.WriteLog(ex); } }
public static void Dispatch(ClientConnection conn, byte[] readBuffer, int start, int length) { try { int num = start + 1; byte pkt = readBuffer[start]; if (conn.State == SlotState.SERVER_AUTH && pkt != 38) { conn.Kick("Incorrect password."); return; } if ((conn.State & SlotState.DISCONNECTING) == 0) { var handler = messageArray[pkt]; var state = conn.State; if (handler != null) { if ((state & handler.IgnoredStates) != 0) { //ProgramLog.Log("ignoring"); } else if ((state & handler.ValidStates) != 0) { //These guys are per thread, so we must ensure they are set or we will end up with strange issues (trust me...) if (Terraria.WorldGen.genRand == null) { Terraria.WorldGen.genRand = new Random((new Random()).Next(Int32.MinValue, Int32.MaxValue)); } if (Terraria.Main.rand == null) { Terraria.Main.rand = new Random((new Random()).Next(Int32.MinValue, Int32.MaxValue)); } handler.Reset(num); handler.Process(conn, readBuffer, length, num); } else { ProgramLog.Log("{0}: sent message {1} in state {2}.", conn.RemoteAddress, (pkt > 0 && pkt <= 76) ? (object)(Packet)pkt : pkt, conn.State); conn.Kick("Invalid operation in this state."); } } else { conn.Kick(String.Format("Message not understood ({0}).", pkt)); } } } catch (Exception e) { string pkt = "invalid packet"; if (readBuffer.Length > start) { pkt = String.Format("packet {0}", (Packet)readBuffer[start]); } ProgramLog.Log("Exception handling {0} of length {1} from {2}\n{3}", pkt, length, conn.RemoteAddress, e); conn.Kick("Server malfunction, please reconnect."); } }
public async Task SendNeedLoginNoticeAsync(ClientConnection client) { NeedLoginNotice notice = new NeedLoginNotice(); await SendNoticeToClientAsync(client, notice).ConfigureAwait(false); }
private async Task SendNoticeToClientAsync(ClientConnection client, Notice notice) { await SendNoticeToClientsAsync(new List <ClientConnection> { client }, notice).ConfigureAwait(false); }
public override void Process(ClientConnection client, byte[] data) { int gameSession = BitConverter.ToInt32(data, 0); Core.Act(s => s.LobbyProcessor.EnterOnWorldProcess(client, gameSession)); }
public RequestProcessorBase(ClientConnection client) { this.Client = client; }
public static void Handle_GetMonthlyGacha(ClientConnection Client, byte last) { Account User = Client.CurrentAccount; Client.SendAsync(new GetMonthlyGacha(User, last)); }
public Client(ClientConnection clientConnection, int id) { this.clientConnection = clientConnection; this.id = id; }
public ClientInvocation(IClientMessage message, ClientConnection boundConnection) : this(message) { _boundConnection = boundConnection; }
public override void Process(ClientConnection conn, byte[] readBuffer, int length, int num) { // ServerSlot slot = Netplay.slots[whoAmI]; // PlayerLoginEvent loginEvent = new PlayerLoginEvent(); // loginEvent.Slot = slot; // loginEvent.Sender = Main.player[whoAmI]; // Server.PluginManager.processHook(Plugin.Hooks.PLAYER_PRELOGIN, loginEvent); // if ((loginEvent.Cancelled || loginEvent.Action == PlayerLoginAction.REJECT) && (slot.state & SlotState.DISCONNECTING) == 0) // { // slot.Kick ("Disconnected by server."); // return; // } string clientName = conn.RemoteAddress.Split(':')[0]; // // if (Server.BanList.containsException(clientName)) // { // slot.Kick ("You are banned from this Server."); // return; // } //if (Program.properties.UseWhiteList && !Server.WhiteList.containsException(clientName)) //{ // conn.Kick ("You are not on the WhiteList."); // return; //} string version = StringCache.FindOrMake(new ArraySegment <byte>(readBuffer, num, length - 1)); Skip(length); var ctx = new HookContext { Connection = conn, }; var args = new HookArgs.ConnectionRequestReceived { Version = version }; HookPoints.ConnectionRequestReceived.Invoke(ref ctx, ref args); if (ctx.CheckForKick()) { return; } if (ctx.Result == HookResult.DEFAULT && !(version == "Terraria" + Globals.TerrariaRelease)) { if (version.Length > 30) { version = version.Substring(0, 30); } ProgramLog.Log("Client version string: {0}", version); conn.Kick(string.Concat("This server requires Terraria ", Globals.TerrariaVersion)); return; } var msg = NewNetMessage.PrepareThreadInstance(); if (ctx.Result == HookResult.ASK_PASS || (Netplay.password != null && Netplay.password != String.Empty)) { conn.State = SlotState.SERVER_AUTH; msg.PasswordRequest(); conn.Send(msg.Output); return; } conn.State = SlotState.ACCEPTED; msg.ConnectionResponse(253 /* arbitrary fake value, true slot assigned later */); conn.Send(msg.Output); }
public SsoTicketModifier(ClientConnection connection, IPacket packetOriginal, Release releaseFrom, Release releaseTarget) : base(connection, packetOriginal, releaseFrom, releaseTarget) { }
//private static void CleanClientFromConnectionsRepository(IClient closedClient) //{ // List<SuperPeerClient> clientList = ConnectionsRepository.GetClients(); // foreach (SuperPeerClient client in clientList.Where(client => client.GetSuperPeerClient() == closedClient)) // { // ConnectionsRepository.RemoveClient(client); // } //} private static void CleanClientRepository(ClientConnection closedClient) { ClientsConnectionsManager.RemoveClient(closedClient); }
public PlayerApprovalEvent(ConnectionAcceptor ca, NetworkPlayerApproval approval, ClientConnection cc, bool AboutToDeny) { this._ca = ca; this._cc = cc; this._approval = approval; this._deny = AboutToDeny; }
public abstract void Process(ClientConnection conn, byte[] readBuffer, int length, int pos);
public static void Handle_FF4D01(ClientConnection Client, byte last) { //SendNoOpCodeString("FF4E010004"); Client.SendAsync(new Login_FF4D01_0X14E(Client.CurrentAccount, last)); }