[en] Context information is missing. (solved)

Topics: Technical Support
Sep 2, 2014 at 3:24 PM
Edited Sep 3, 2014 at 6:42 PM
UPD: resolved by myself:)

Greetings, it seems, i need a help here.
Just for a test made this on the client side:
Image
public void TestConnect(string login, string password)
{
   Hashtable credentials = new Hashtable();
                    credentials.Add(AuthRequestMessage.CREDENTIAL_USERNAME, login);
                    credentials.Add(AuthRequestMessage.CREDENTIAL_PASSWORD, password);

                    TcpDuplexClientProtocolSetup protocol = new TcpDuplexClientProtocolSetup(false);
                    SrvAddr srvAddr = new SrvAddr(_serverAddress, _serverPort, ServerType.LoginServer);
                    using (var connection = new ServerConnection(srvAddr.Value, protocol, credentials, false, true))
                    {
                        _behaviour = connection.CreateProxy<IServerBehaviour>();
                        StartHeartBeat();
                    }
}

 private void StartHeartBeat(int beatInterval = 1000)
        {
            ThreadPool.QueueUserWorkItem(x =>
            {
                    try
                    {
                        _behaviour.ServerHeartbeat(HeartBeatEcho);

                        Thread.Sleep(beatInterval);
                    }
                    catch (Exception)
                    {
                          throw;
                    }
            });
        }

        private void HeartBeatEcho()
        {
            //
        }
And here is my server class:
    public class ServerBase<T1, T2> : IDisposable
        where T1 : IServerBehaviour
        where T2 : ServerBehaviour
    {
        public ServerBase(int port, ServerType serverType)
        {
            _serverPort = port;
            _serverType = serverType;

            _protocol = new TcpDuplexServerProtocolSetup(port, new NullAuthenticationProvider(), false);
            PredefinedSettings();
        }

        public ServerBase(int port, ServerType serverType, IAuthenticationProvider authenticationProvider)
        {
            _serverPort = port;
            _serverType = serverType;

            _authenticationProvider = authenticationProvider;

            _protocol = new TcpDuplexServerProtocolSetup(port, authenticationProvider, false);
            PredefinedSettings();
        }

        private void PredefinedSettings()
        {
            Console.Title = string.Format("{0}: port {1}", _serverType, _serverPort);
        }

        public void Start()
        {
            using (ZyanComponentHost host = new ZyanComponentHost(_serverType.ToString(), _protocol))
            {
                host.PollingEventTracingEnabled = true;
                host.ClientHeartbeatReceived += ClientHeartbeatReceived;

                host.RegisterComponent<T1, T2>(ActivationType.Singleton);

                host.ClientLoggedOn += ClientLoggedOn;
                host.ClientLoggedOff += ClientLoggedOff;
                host.ClientSessionTerminated += ClientSessionTerminated;

                Console.WriteLine(GetWelcomeString());
                Console.ReadLine();
            }
        }

        protected virtual void ClientSessionTerminated(object sender, LoginEventArgs e)
        {
        }

        protected virtual void ClientLoggedOff(object sender, LoginEventArgs e)
        {
        }

        protected virtual void ClientLoggedOn(object sender, LoginEventArgs e)
        {
        }

        protected virtual void ClientHeartbeatReceived(object sender, ClientHeartbeatEventArgs e)
        {
        }

        public void Dispose()
        {
            // throw new NotImplementedException();
        }

        private string GetWelcomeString()
        {
            var version = new Common.Version();
            string message = @"[Server Build]: {0}@[READY] {1} is up and running on port: {2}";

            message = message.Replace("@", Environment.NewLine);

            return string.Format(message, version.GetVersionString(), _serverType, _serverPort);
        }

        private readonly int _serverPort;
        private readonly IAuthenticationProvider _authenticationProvider;
        private readonly TcpDuplexServerProtocolSetup _protocol;
        private readonly ServerType _serverType;
    }
}
My component class:
public class ServerBehaviour: IServerBehaviour
{
    public void ServerHeartbeat(Action heartBeatEcho)
    {
        if (heartBeatEcho != null)
        {
            try
            {
                heartBeatEcho();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}

Instantiating like this:


       IAccountManager accountManager = AccountManager.Instance();
        AuthorizationModule authorizationModule = new AuthorizationModule(accountManager);
        var t = new ServerBase<IServerBehaviour, ServerBehaviour>(3910, ServerType.LoginServer, authorizationModule);
        //InitLogicHere
        t.Start();
After request _behaviour.ServerHeartbeat(HeartBeatEcho); , i'm getting "Context information is missing" on the server side.
What's wrong here?
Marked as answer by Jesset3r on 9/3/2014 at 10:41 AM
Coordinator
Sep 7, 2014 at 4:01 PM
Hi!

Sorry for my late reply.
Just for reference, could you please post the solution?
What was the problem?