/// <summary> /// Adds the <see cref="GladNetInputFormatter"/> and <see cref="GladNetOutputFormatter"/> to the known formatters. /// Also registers the gladnet media header to map to these formatters. /// </summary> /// <param name="builder">Builder to chain off.</param> /// <param name="serializerStrat">Serialization strategy</param> /// <param name="deserializerStrat">Deserialization strategy.</param> /// <param name="registry">Serialization registry.</param> /// <returns>The fluent <see cref="IServiceCollection"/> instance.</returns> public static IServiceCollection AddGladNet(this IServiceCollection builder, ISerializerStrategy serializerStrat, IDeserializerStrategy deserializerStrat, ISerializerRegistry registry) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (serializerStrat == null) { throw new ArgumentNullException(nameof(serializerStrat)); } if (deserializerStrat == null) { throw new ArgumentNullException(nameof(deserializerStrat)); } if (registry == null) { throw new ArgumentNullException(nameof(registry)); } //need to register these types registry.Register(typeof(NetworkMessage)); registry.Register(typeof(PacketPayload)); registry.Register(typeof(RequestMessage)); registry.Register(typeof(ResponseMessage)); return(builder.AddMvcCore() .AddGladNetFormatters(serializerStrat, deserializerStrat).Services); }
private void RegisterMessages() { //TODO: Extension for message registeration registry.RegisterAuthenticationPayloads(); registry.Register(typeof(NetworkMessage)); registry.Register(typeof(RequestMessage)); registry.Register(typeof(ResponseMessage)); registry.RegisterServerSelectionPayloads(); //TODO: Add async handling so that we don't need to register here }
public override void RegisterPayloadTypes(ISerializerRegistry registry) { registry.Register(typeof(NetworkMessage)); registry.Register(typeof(EntitySpawnEventPayload)); registry.Register(typeof(ClaimSessionResponsePayload)); registry.Register(typeof(ClaimSessionRequestPayload)); registry.Register(typeof(EntityPositionUpdateEvent)); registry.Register(typeof(PlayerMoveRequestPayload)); registry.Register(typeof(EntityInteractionRequestPayload)); registry.Register(typeof(EntityStateChangedEvent)); }