Hello there,
For some reason the same issue arose for me now too, with the difference that it happened to me due to the changes in the last class:
Code:
private void Login(string email, string password)
{
_state = LoginState.Sending;
NetworkManager.Instance.Dispatch(new LoginCommand(email, password), response =>
{
if (response.IsValid)
{
if (response.Response == null)
Debug.Log(string.Format("Response is null of type {0}", response.ToString()));
GameManager.Instance.UserId = response.Response.Id; // <-- That is the null exception on response.Response
return;
}
_state = LoginState.Error;
_error = response.ToErrorString();
});
}
After debugging what I have found is that the NetworkManagercorrectly receives the Response parameter from the server upon dispatching the login command. Meaning the Response paramater is filled correctly server side, and received correctly client side. However, for some reason the response used in the Login function is not filled with the correct data.
That is my Dispatch function:
Code:
public void Dispatch<TResponse>(ICommand<TResponse> command, Action<CommandContext<TResponse>> action) where TResponse : ICommandResponse
{
//! Extract commandId first
var commandId = Guid.NewGuid();
_commandCallbacks.Add(commandId, serverResponse =>
{
var parameters = serverResponse.Parameters;
var response = default(TResponse);
//! Debugging shows that response here is _correctly_ filled
if (parameters.ContainsKey((byte)MMoOperationResponseParameter.CommandResponse))
response = DeserializeBSON<TResponse>((byte[])parameters[(byte)MMoOperationResponseParameter.CommandResponse]);
var propertyErrors = (byte[])parameters[(byte)MMoOperationResponseParameter.PropertyErrors];
var operationErrors = (byte[])parameters[(byte)MMoOperationResponseParameter.OperationErrors];
action(new CommandContext<TResponse>(
response,
DeserializeBSON<IDictionary<string, IEnumerable<string>>>(propertyErrors),
DeserializeBSON<IEnumerable<string>>(operationErrors, true)));
});
DispatchInternal(command, commandId);
}
Any idea where else to look? I am running out of ideas a little.