/// <summary> /// 傳送給目標玩家(玩家名稱) /// </summary> /// <param name="type">伺服器訊息種類</param> /// <param name="playerName">玩家名稱</param> /// <param name="inMsg">已封裝的訊息</param> private void SendToPlayer(ServerMessageType type, string playerName, string inMsg) { string code = EnumEx.GetOrderByEnum(type).ToString(); byte[] byteDatas = Encoding.Default.GetBytes(code + ">" + inMsg); SendToClient((Socket)socketHT[playerName], byteDatas); }
/// <inheritdoc/> public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { string content = datareader.ReadString(); string path; var username = _entityBackend.GetPlayerEntityId(session); var mount = drivemgr.GetDriveFromPathData(username, content, out path); if (mount == null) { datawriter.Write("Mountpoint not found."); return(ServerResponseType.REQ_ERROR); } if (mount.DirectoryExists(path)) { datawriter.Write("Cannot write file data to a directory."); return(ServerResponseType.REQ_ERROR); } try { int len = datareader.ReadInt32(); byte[] bytes = datareader.ReadBytes(len); mount.WriteAllBytes(path, bytes); return(ServerResponseType.REQ_SUCCESS); } catch (Exception ex) { datawriter.Write(ex.Message); return(ServerResponseType.REQ_ERROR); } }
public ServerResponseType HandleMessage(Backend.Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { if (backend.IsMultiplayer) { return(ServerResponseType.REQ_ERROR); } var ipaddr = datareader.ReadUInt32(); ushort port = 80; if (datareader.BaseStream.Length - datareader.BaseStream.Position >= 2) { port = datareader.ReadUInt16(); } if (_ip.GrabEntity(ipaddr) == null) { return(ServerResponseType.REQ_ERROR); } var entity = _entityManager.GetPlayerEntityId(session); var playerIp = _ip.FetchAllIPs(entity); if (playerIp.Length == 0) { return(ServerResponseType.REQ_ERROR); } try { _ip.MakeConnection(ipaddr, playerIp[0].Address, port); return(ServerResponseType.REQ_SUCCESS); } catch { return(ServerResponseType.REQ_ERROR); } }
void ILidgrenServerEvents.HandleReplyMessage(NetConnection netConnection, ServerMessageType messageType, int feedback, string jsonBody) { try { //Try and find the client player ClientPlayer clientPlayer = clientPlayers.Find(x => x.netConnection == netConnection); //If not found then report error if (clientPlayer == null) { throw new Exception("Can't find client object from net connection"); } //Switch on the message type and have it handled by specific methods so as to not clutter this area switch (messageType) { case ServerMessageType.PrepMission: PrepMission(clientPlayer, feedback, jsonBody); break; default: throw new Exception($"Unhandled message type {messageType}"); } } catch (Exception ex) { LogMessage($"Error handling reply message type {messageType} with feedback {feedback} from {netConnection.RemoteEndPoint}, error: {ex.Message}"); } }
/// <inheritdoc/> public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { string content = datareader.ReadString(); string path; var username = _entityBackend.GetPlayerEntityId(session); var mount = drivemgr.GetDriveFromPathData(username, content, out path); if (mount == null) { datawriter.Write("Mountpoint not found."); return(ServerResponseType.REQ_ERROR); } if (!mount.FileExists(path) && !mount.DirectoryExists(path)) { datawriter.Write("File or directory not found.."); return(ServerResponseType.REQ_ERROR); } try { var finf = mount.GetFileInfo(path); datawriter.Write(JsonConvert.SerializeObject(finf)); return(ServerResponseType.REQ_SUCCESS); } catch (Exception ex) { datawriter.Write(ex.Message); return(ServerResponseType.REQ_ERROR); } }
/// <inheritdoc/> public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { string content = datareader.ReadString(); string path; var username = _entityBackend.GetPlayerEntityId(session); var mount = drivemgr.GetDriveFromPathData(username, content, out path); if (mount == null) { datawriter.Write("Mountpoint not found."); return(ServerResponseType.REQ_ERROR); } if (!path.Contains("/")) { datawriter.Write("Invalid pathspec."); return(ServerResponseType.REQ_ERROR); } try { mount.CreateDirectory(path); } catch (Exception ex) { datawriter.Write(ex.Message); return(ServerResponseType.REQ_ERROR); } return(ServerResponseType.REQ_SUCCESS); }
/// <inheritdoc/> public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { string content = datareader.ReadString(); string path; var username = _entityBackend.GetPlayerEntityId(session); var mount = drivemgr.GetDriveFromPathData(username, content, out path); if (mount == null) { datawriter.Write("Mountpoint not found."); return(ServerResponseType.REQ_ERROR); } if (mount.FileExists(path)) { mount.DeleteFile(path); return(ServerResponseType.REQ_SUCCESS); } if (mount.DirectoryExists(path)) { mount.DeleteDirectory(path); return(ServerResponseType.REQ_SUCCESS); } datawriter.Write("File or directory not found."); return(ServerResponseType.REQ_ERROR); }
protected ServerMessage(Socket destination, ServerMessageType serverMessageType, MessageTarget messageTarget) : base(MessageType.SERVER) { Destination = destination; ServerMessageType = serverMessageType; MessageTarget = messageTarget; }
public ServerMessage(string raw) { Raw = raw; Message = Raw.Substring(17); Type = CalculateType(); Player = GeneratePlayer(); }
/// <summary> /// Handles an incoming server message. /// </summary> /// <param name="messagetype">The type of the message</param> /// <param name="session_id">The caller user ID</param> /// <param name="dgram">The message body</param> /// <param name="returndgram">The returned message body</param> /// <returns>The result of the handler.</returns> public ServerResponseType HandleMessage(ServerMessageType messagetype, string session_id, byte[] dgram, out byte[] returndgram) { #if HANG_DEBUG Logger.Log("Attempting to handle a " + messagetype + "..."); #endif var handler = _handlers.FirstOrDefault(x => x.HandledMessageType == messagetype); if (handler == null) { Logger.Log("WARNING: No handler for this message. Returning error."); returndgram = new byte[] { }; return(ServerResponseType.REQ_ERROR); } else { bool sessionRequired = handler.GetType().GetCustomAttributes(false).FirstOrDefault(x => x is RequiresSessionAttribute) != null; if (sessionRequired) { if (string.IsNullOrWhiteSpace(session_id)) { returndgram = new byte[0]; return(ServerResponseType.REQ_LOGINREQUIRED); } } using (var memstr = new MemoryStream(dgram)) { using (var rms = new MemoryStream()) { var result = handler.HandleMessage(this, messagetype, session_id, new BinaryReader(memstr), new BinaryWriter(rms)); returndgram = rms.ToArray(); return(result); } } } }
/// <inheritdoc/> public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { string content = datareader.ReadString(); string path; var username = _entityBackend.GetPlayerEntityId(session); var mount = drivemgr.GetDriveFromPathData(username, content, out path); if (mount == null) { datawriter.Write("Mountpoint not found."); return(ServerResponseType.REQ_ERROR); } if (!mount.DirectoryExists(path)) { datawriter.Write("Directory not found.."); return(ServerResponseType.REQ_ERROR); } try { var files = mount.GetDirectories(path); datawriter.Write(files.Length); foreach (var file in files) { datawriter.Write(file); } } catch (Exception ex) { datawriter.Write(ex.Message); return(ServerResponseType.REQ_ERROR); } return(ServerResponseType.REQ_SUCCESS); }
/// <summary> /// 傳送給目標玩家(玩家插槽) /// </summary> /// <param name="type">伺服器訊息種類</param> /// <param name="sk">目標玩家的插槽</param> /// <param name="inMsg">已封裝的訊息</param> private void SendToSocket(ServerMessageType type, Socket sk, string inMsg) { string code = EnumEx.GetOrderByEnum(type).ToString(); byte[] byteDatas = Encoding.Default.GetBytes(code + ">" + inMsg); SendToClient(sk, byteDatas); }
/// <summary> /// Called when replying to messages recieved from the client /// </summary> private void SendReplyMessage(ServerMessageType messageType, int feedback, string jsonBody = null) { //Determine how to send the data DetermineMethodandChannel(messageType, out NetDeliveryMethod deliverymethod, out int?sequenceChannel); //Send the message lidgrenClient.SendMessage(false, (byte)messageType, deliverymethod, (byte)feedback, sequenceChannel, jsonBody); }
/// <summary> /// Sends data to the <see cref="INetworkSender"/>. This method is thread-safe. /// </summary> /// <param name="sender">The <see cref="INetworkSender"/> to use to send the data.</param> /// <param name="message">GameMessage to send to the User.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="message"/>.</param> /// <param name="parameters">Message parameters.</param> public static void Send(this INetworkSender sender, GameMessage message, ServerMessageType messageType, params object[] parameters) { using (var pw = ServerPacket.SendMessage(message, parameters)) { sender.Send(pw, messageType); } }
public ServerMessageArgs(DateTime time, string userName, ServerMessageType type, string content, int teamId) { Time = time; UserName = userName; Type = type; Content = content; TeamId = teamId; }
/// <summary> /// Called when creating a new message from the server /// </summary> private void SendNewMessage(NetConnection netConnection, ServerMessageType messageType, string jsonBody = null) { //Determine how to send the data DetermineMethodandChannel(messageType, out NetDeliveryMethod deliverymethod, out int?sequenceChannel); //Send the message lidgrenServer.SendMessage(true, (byte)messageType, netConnection, deliverymethod, null, sequenceChannel, jsonBody); }
void handleRenderMessage(ServerMessageType type, int i, int len) { int tileX = bytes[i + 4] * 128 + bytes[i + 5]; int tileY = bytes[i + 6] * 128 + bytes[i + 7]; switch (type) { //uncompressed tile case ServerMessageType.TILE: throw new System.Exception("Rendering uncompressed data not yet implemented"); //solid color tile case ServerMessageType.SOLID_TILE: Color32 solidColor = new Color32( (byte)(bytes[i + 8] << 1), (byte)(bytes[i + 9] << 1), (byte)(bytes[i + 10] << 1), 255); for (int j = 0; j < TileRenderController.TILE_SIZE_SQUARED; j++) { tileColors[j] = solidColor; } break; //run-length encoding with color in 3 bytes case ServerMessageType.RLE24_TILE: throw new System.Exception("Rendering 3-byte-run-length-encoded data not yet implemented"); //run-length encoding with color in 2 bytes case ServerMessageType.RLE16_TILE: int max = i + len; int runindex = 0; for (int j = i + 8; j < max; j += 3) { //get the byte values from the array int runlength = bytes[j]; int byte1 = bytes[j + 1], byte2 = bytes[j + 2]; //build the color from the bit values Color32 color = new Color32( (byte)((byte1 >> 2 & 0x1F) << 3), (byte)((((byte1 & 3) << 3) | (byte2 >> 4 & 7)) << 3), (byte)((byte2 & 0xF) << 4), 255); //fill the colors that will be used in the texture for (int runmax = runindex + runlength; runindex < runmax; runindex++) { //fix up the index that we get from foldit, swap x and y tileColors[runindex % TileRenderController.TILE_SIZE * TileRenderController.TILE_SIZE + (runindex / TileRenderController.TILE_SIZE)] = color; } } //Debug.Log(runindex); break; //run-length encoding with color in 1 byte case ServerMessageType.RLE8_TILE: throw new System.Exception("Rendering 1-byte-run-length-encoded data not yet implemented"); } tileRenderController.SetTile(tileX, tileY, tileColors); }
public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { string recipient = datareader.ReadString(); string messagetext = datareader.ReadString(); string sender = _entityBackend.GetPlayerEntityId(session); _chat.AddMessage(sender, (recipient == "group") ? null : recipient, messagetext); return(ServerResponseType.REQ_SUCCESS); }
/// <inheritdoc/> public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { var savemgr = backend.GetBackendComponent <SaveManager>(); string key = datareader.ReadString(); string val = datareader.ReadString(); savemgr.SetValue(session, key, val); return(ServerResponseType.REQ_SUCCESS); }
public static void ResponseFromServer(Packet p) { ServerMessageType type = (ServerMessageType)p.ReadByte(); string msg = p.ReadASCII(p.ReadUShort()); EventSink.InvokeServerResponseMessage(new ResponseServerEntry { Type = type, Message = msg }); }
public static Offset <ServerMessage> CreateServerMessage(FlatBufferBuilder builder, ServerMessageType msg_type = ServerMessageType.NONE, int msgOffset = 0) { builder.StartObject(2); ServerMessage.AddMsg(builder, msgOffset); ServerMessage.AddMsgType(builder, msg_type); return(ServerMessage.EndServerMessage(builder)); }
/// <summary> /// Send a message to a server. /// </summary> /// <param name="type">The type of message to send.</param> /// <param name="body">The body of the message.</param> /// <param name="onResponse">A callback to run when the server responds.</param> /// <returns>A <see cref="Task"/> which may be awaited with <see langword="await"/> keyword or with <see cref="Task.Wait()"/>.</returns> public async Task SendMessage(ServerMessageType type, byte[] body, Action <ServerResponseType, BinaryReader> onResponse) { await Task.Run(() => { _messageHandled.WaitOne(); _messageHandled.Reset(); string muid = Guid.NewGuid().ToString(); Logger.Log($"Sending message to server: {type} {muid} (body is {body?.Length} bytes long)"); _responses[muid] = null; lock (_writer) { _writer.Write(lenInt(muid.Length) + muid.Length + lenInt(_session.Length) + _session.Length + 8 + (body?.Length ?? 0)); _writer.Write(muid); _writer.Write((int)type); _writer.Write(_session); _writer.Write(body?.Length ?? 0); if (body != null) { _writer.Write(body); } _writer.Flush(); } _messageHandled.Set(); PlexServerHeader hdr; while (_responses[muid] == null) { _messageReceived.WaitOne(); } if (!_responses.TryRemove(muid, out hdr)) { throw new IOException("TryRemove() returned false"); } var response = (ServerResponseType)hdr.Message; if (response == ServerResponseType.REQ_LOGINREQUIRED) { Disconnect("You must be signed into an itch.io account to play Multiplayer."); } else { if (hdr.Content.Length > 0) { using (var memstr = new MemoryStream(hdr.Content)) { using (var memreader = new BinaryReader(memstr, Encoding.UTF8)) { onResponse?.Invoke(response, memreader); } } } else { onResponse?.Invoke(response, null); // what? } } }); }
/// <summary> /// 傳送給所有玩家 /// </summary> /// <param name="type">伺服器訊息種類</param> /// <param name="inMsg">已封裝的訊息</param> private void SendToAll(ServerMessageType type, string inMsg = "") { string code = EnumEx.GetOrderByEnum(type).ToString(); byte[] byteDatas = Encoding.Default.GetBytes(code + ">" + inMsg); foreach (Socket sk in socketHT.Values) { SendToClient(sk, byteDatas); } }
public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { string entity = _entity.GetPlayerEntityId(session); string to = datareader.ReadString(); string subject = datareader.ReadString(); string text = datareader.ReadString(); _email.SendMessage(entity, to, subject, text); return(ServerResponseType.REQ_SUCCESS); }
/// <inheritdoc/> public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { PseudoTerminal _master = null; PseudoTerminal _slave = null; var options = new TerminalOptions(); options.LFlag = PtyConstants.ICANON; options.C_cc[PtyConstants.VERASE] = (byte)'\b'; options.C_cc[PtyConstants.VEOL] = (byte)'\r'; options.C_cc[PtyConstants.VEOL2] = (byte)'\n'; PseudoTerminal.CreatePair(out _master, out _slave, options); int slaveRemoteId = _remoteStreams.Create(_slave, session); var stdout = new StreamWriter(new BroadcastingStream(backend, session)); stdout.AutoFlush = true; var stdin = new StreamReader(_master); string commandname = datareader.ReadString(); int argCount = datareader.ReadInt32(); string[] argv = new string[argCount]; for (int i = 0; i < argCount; i++) { argv[i] = datareader.ReadString(); } var trmmgr = backend.GetBackendComponent <TerminalManager>(); Task.Run(() => { try { trmmgr.RunCommand(backend, commandname, argv, session, stdin, stdout); } catch (TerminationRequestException) { Logger.Log("Terminated command."); } finally { stdout.Write((char)0x02); } }); datawriter.Write(slaveRemoteId); return(ServerResponseType.REQ_SUCCESS); }
/// <summary> /// Sends data to all users in the map. This method is thread-safe. /// </summary> /// <param name="data">BitStream containing the data to send to the users.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="data"/>.</param> public void Send(BitStream data, ServerMessageType messageType) { if (_users.Count == 0) { return; } foreach (var user in Users) { user.Send(data, messageType); } }
/// <inheritdoc/> public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { var trmmgr = backend.GetBackendComponent <TerminalManager>(); var cmds = trmmgr.GetCommandList().ToArray(); datawriter.Write(cmds.Length); foreach (var cmd in cmds) { datawriter.Write(cmd.Key); datawriter.Write(cmd.Value); } return(ServerResponseType.REQ_SUCCESS); }
/// <inheritdoc/> public ServerResponseType HandleMessage(Backend backend, ServerMessageType message, string session, BinaryReader datareader, BinaryWriter datawriter) { var username = _entityBackend.GetPlayerEntityId(session); var mounts = drivemgr.GetDrivesForUser(username); datawriter.Write(mounts.Count); foreach (var mount in mounts) { datawriter.Write(mount.Value); datawriter.Write(mount.Key); } return(ServerResponseType.REQ_SUCCESS); }
public PRemoteMessage(ServerMessageType type, string keyword, List <string> args) : base(0x21) { WriteByte((byte)type); WriteByte((byte)(keyword.Length + 0)); WriteASCII(keyword); WriteByte((byte)args.Count); foreach (string a in args) { WriteByte((byte)(a.Length + 0)); WriteASCII(a); } }
public static StreamGeometry GetIcon(ServerMessageType messageType) { switch (messageType) { case ServerMessageType.Info: return(InfoIcon); case ServerMessageType.NewVersion: return(NewVersionIcon); default: return(null); } }
public static SolidColorBrush GetIconFill(ServerMessageType messageType) { switch (messageType) { case ServerMessageType.Info: return(InfoColor); case ServerMessageType.NewVersion: return(NewVersionColor); default: return(WpfUtil.BlackBrush); } }
/// <summary> /// Sends data to the <see cref="INetworkSender"/>. This method is thread-safe. /// </summary> /// <param name="sender">The <see cref="INetworkSender"/> to use to send the data.</param> /// <param name="data">BitStream containing the data to send to the User.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="data"/>.</param> public static void Send(this INetworkSender sender, BitStream data, ServerMessageType messageType) { if (!sender.IsConnected) { const string errmsg = "Send to `{0}` failed - not connected."; if (log.IsErrorEnabled) log.ErrorFormat(errmsg, sender); return; } NetDeliveryMethod method; int seqChannel; messageType.GetDeliveryMethod(out method, out seqChannel); sender.Send(data, method, seqChannel); }
/// <summary> /// Sends data to the <see cref="INetworkSender"/>. This method is thread-safe. /// </summary> /// <param name="sender">The <see cref="INetworkSender"/> to use to send the data.</param> /// <param name="message">GameMessage to send to the User.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="message"/>.</param> public static void Send(this INetworkSender sender, GameMessage message, ServerMessageType messageType) { sender.Send(message, messageType, null); }
public virtual void SendPlainObjectToServer(ServerMessageType messageType, object dataObject, List<IPEndPoint> receivers) { OutgoingMessage com = ServerMessageFormatter.CreateOutgoingMessage( (int)messageType, Serializer.GetBytes(dataObject), receivers); InternalOutgoingMessageQueue.Add(com); }
/// <summary> /// Send a packet to every user in the map within a reasonable range from the origin. Use this for packets /// that only affect those who are already in view from the origin such as brief visual effects. /// </summary> /// <param name="origin">Position in which the event creating the packet triggered.</param> /// <param name="data">BitStream containing the data to send.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="data"/>.</param> public void SendToArea(Vector2 origin, BitStream data, ServerMessageType messageType) { if (data == null) return; var screenSize = GameData.ScreenSize * 1.25f; var min = origin - screenSize; var max = origin + screenSize; foreach (var user in Users) { Debug.Assert(user != null, "There shouldn't be null users in the Users list!"); var p = user.Position; if (p.X > min.X && p.Y > min.Y && p.X < max.X && p.Y < max.Y) user.Send(data, messageType); } }
/// <summary> /// Send a packet to every user in the map within a reasonable range from the origin. Use this for packets /// that only affect those who are already in view from the origin such as brief visual effects. /// </summary> /// <param name="origin">The <see cref="ISpatial"/> that the event comes from.</param> /// <param name="data">BitStream containing the data to send.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="data"/>.</param> public void SendToArea(ISpatial origin, BitStream data, ServerMessageType messageType) { SendToArea(origin.Position + (origin.Size / 2f), data, messageType); }
/// <summary> /// Sends data to all users in the map. This method is thread-safe. /// </summary> /// <param name="message">GameMessage to send.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="message"/>.</param> /// <param name="parameters">Message parameters.</param> public void Send(GameMessage message, ServerMessageType messageType, params object[] parameters) { if (_users.Count == 0) return; using (var pw = ServerPacket.SendMessage(message, parameters)) { foreach (var user in Users) { user.Send(pw, messageType); } } }
/// <summary> /// Sends data to all users in the map. This method is thread-safe. /// </summary> /// <param name="message">GameMessage to send.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="message"/>.</param> public void Send(GameMessage message, ServerMessageType messageType) { Send(message, messageType, null); }
/// <summary> /// Sends data to all users in the map. This method is thread-safe. /// </summary> /// <param name="data">BitStream containing the data to send to the users.</param> /// <param name="messageType">The <see cref="ServerMessageType"/> to use for sending the <paramref name="data"/>.</param> public void Send(BitStream data, ServerMessageType messageType) { if (_users.Count == 0) return; foreach (var user in Users) { user.Send(data, messageType); } }
public ReceiveServerReferenceHandler(ServerNetworkManager manager, ServerMessageType target) : base(manager, target) { }
void handleRenderMessage(ServerMessageType type, int i, int len) { int tileX = bytes[i + 4] * 128 + bytes[i + 5]; int tileY = bytes[i + 6] * 128 + bytes[i + 7]; switch (type) { //uncompressed tile case ServerMessageType.TILE: throw new System.Exception("Rendering uncompressed data not yet implemented"); //solid color tile case ServerMessageType.SOLID_TILE: Color32 solidColor = new Color32( (byte)(bytes[i + 8] << 1), (byte)(bytes[i + 9] << 1), (byte)(bytes[i + 10] << 1), 255); for (int j = 0; j < TileRenderController.TILE_SIZE_SQUARED; j++) tileColors[j] = solidColor; break; //run-length encoding with color in 3 bytes case ServerMessageType.RLE24_TILE: throw new System.Exception("Rendering 3-byte-run-length-encoded data not yet implemented"); //run-length encoding with color in 2 bytes case ServerMessageType.RLE16_TILE: int max = i + len; int runindex = 0; for (int j = i + 8; j < max; j += 3) { //get the byte values from the array int runlength = bytes[j]; int byte1 = bytes[j + 1], byte2 = bytes[j + 2]; //build the color from the bit values Color32 color = new Color32( (byte)((byte1 >> 2 & 0x1F) << 3), (byte)((((byte1 & 3) << 3) | (byte2 >> 4 & 7)) << 3), (byte)((byte2 & 0xF) << 4), 255); //fill the colors that will be used in the texture for (int runmax = runindex + runlength; runindex < runmax; runindex++) { //fix up the index that we get from foldit, swap x and y tileColors[runindex % TileRenderController.TILE_SIZE * TileRenderController.TILE_SIZE + (runindex / TileRenderController.TILE_SIZE)] = color; } } //Debug.Log(runindex); break; //run-length encoding with color in 1 byte case ServerMessageType.RLE8_TILE: throw new System.Exception("Rendering 1-byte-run-length-encoded data not yet implemented"); } tileRenderController.SetTile(tileX, tileY, tileColors); }
public GameServerMessageHandler(GameNetworkManager2 manager, ServerMessageType target) : base(manager, target) { Manager = manager; }
/// <summary> /// Tries to send data to the <see cref="Character"/> if they implement <see cref="INetworkSender"/>. /// </summary> /// <param name="gameMessage">The game message.</param> /// <param name="messageType">The type of message.</param> void TrySend(GameMessage gameMessage, ServerMessageType messageType) { var comm = this as INetworkSender; if (comm != null) comm.Send(gameMessage, messageType); }
/// <summary> /// Tries to send data to the <see cref="Character"/> if they implement <see cref="INetworkSender"/>. /// </summary> /// <param name="gameMessage">The game message.</param> /// <param name="messageType">The type of message.</param> /// <param name="parameters">The message parameters.</param> void TrySend(GameMessage gameMessage, ServerMessageType messageType, params object[] parameters) { var comm = this as INetworkSender; if (comm != null) comm.Send(gameMessage, messageType, parameters); }
public ServerReferenceRequestHandler(ServerNetworkManager manager, ServerMessageType target) : base(manager, target) { }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// internal ServerMessage(ServerMessageType type, string text) { _type = type; _text = text; }
public PlayerRemovalHandler(GatewayNetworkManager2 manager, ServerMessageType target) : base(manager, target) { }
public MessageFromClientHandler(GameNetworkManager2 manager, ServerMessageType target) : base(manager, target) { }