public void JoinRoom(string roomName) { _writer.Reset(); _writer.Write((byte)0); _writer.Write(roomName); _connection.Send(_writer.ToArray()); }
public void SendNewClient(RoomEventData newClient) { _writer.Reset(); _writer.Write((byte)0); _writer.Write(newClient.roomName); _writer.Write(newClient.client.id); _connection.Send(_writer.ToArray()); }
public override byte[] Serialize(object obj) { Type type = obj.GetType(); if (!MainEntity && typeof(EntityBase).IsAssignableFrom(type)) { return(((EntityBase)obj).Index.ToByteArray()); } MainEntity = false; BinaryDataWriter writer = new BinaryDataWriter(); var properties = type.GetProperties(); for (byte i = 0; i < properties.Length; i++) { var property = properties[i]; #region 判断是否有效数据 if (!property.CanRead || !property.CanWrite) { continue; } PropertyAuthenticationAttribute authenticate = property.GetCustomAttributes(typeof(PropertyAuthenticationAttribute), false).FirstOrDefault() as PropertyAuthenticationAttribute; if (authenticate != null) { if (!authenticate.AllowAnonymous && !MemberManager.IsSigned) { continue; } if (!RoleManager.HasRoles(authenticate.ViewRolesRequired)) { continue; } } #endregion writer.WriteByte(i); var data = Serialize(property.GetValue(obj, null)); writer.WriteBytes(data); } MainEntity = true; return(writer.ToArray()); }
public override byte[] Serialize(object obj) { Type type = obj.GetType(); if (!MainEntity && typeof(EntityBase).IsAssignableFrom(type)) { return ((EntityBase)obj).Index.ToByteArray(); } MainEntity = false; BinaryDataWriter writer = new BinaryDataWriter(); var properties = type.GetProperties(); for (byte i = 0; i < properties.Length; i++) { var property = properties[i]; #region 判断是否有效数据 if (!property.CanRead || !property.CanWrite) continue; PropertyAuthenticationAttribute authenticate = property.GetCustomAttributes(typeof(PropertyAuthenticationAttribute), false).FirstOrDefault() as PropertyAuthenticationAttribute; if (authenticate != null) { if (!authenticate.AllowAnonymous && !MemberManager.IsSigned) continue; if (!RoleManager.HasRoles(authenticate.ViewRolesRequired)) continue; } #endregion writer.WriteByte(i); var data = Serialize(property.GetValue(obj, null)); writer.WriteBytes(data); } MainEntity = true; return writer.ToArray(); }