private string JoinQueue() { ServusLogin_Only obj = RegisterOnly(); LoginViaOnly(obj); ServusMessage msg = ServusProtobufBasicFactory.createServusMessage(Modulename.Queue, QueueFunctions.QueueJoin); msg.ValueString = "testGame_1p"; _connection.SendMessage(msg); sleepModifier(500); Assert.Equal(3, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.Equal(typeof(ServusMessage), _receivedEvents[1].GetType()); Assert.Equal(typeof(ServusMessage), _receivedEvents[2].GetType()); Assert.False(_receivedEvents[0].Error); Assert.False(_receivedEvents[1].Error); Assert.False(_receivedEvents[2].Error); Assert.Equal(QueueFunctions.QueueGameid, _receivedEvents[1].Queuefunc); Assert.True(null != _receivedEvents[1].ValueString); Assert.Equal(TestGameFunctions.TgBegin, _receivedEvents[0].TestGamefunc); Assert.Equal("Dummy", _receivedEvents[0].ValueString); Assert.Equal(QueueFunctions.QueueJoin, _receivedEvents[2].Queuefunc); string returnString = _receivedEvents[1].ValueString; _receivedEvents.Clear(); return(returnString); }
internal void _internalClient_recieveMessage(ServusMessage message) { switch (message.Modul) { case Modulename.AuthFb: if (message.Error == true) { ChangeServerStateStatus(FbStates.LoginError); } else { HandleNormalAuthMessage(message); } break; case Modulename.AuthUserdata: if (message.Error == true) { ChangeServerStateStatus(FbStates.LoginError); } else { HandleNormalUserDataMessage(message); } break; default: break; } }
public static ServusMessage CreateServusMessage(string playerid) { ServusMessage internalServusMsg = new ServusMessage { Modul = Modulename.AuthUserdata, Authfunc = AuthFunctions.AuthPicture, ValueString = playerid }; return(internalServusMsg); }
public static ServusMessage createServusMessage(Modulename mod, BasicFunctions func) { ServusMessage internalServusMsg = new ServusMessage { Modul = mod, Basicfunc = func }; return(internalServusMsg); }
public static ServusMessage createEchoGameMessage(Modulename mod, TestGameFunctions func, string gameID) { ServusMessage internalServusMsg = new ServusMessage { Modul = mod, TestGamefunc = func, GameID = gameID }; return(internalServusMsg); }
public static ServusMessage createServusMessage(Modulename mod, long cbID, AuthFunctions func) { ServusMessage internalServusMsg = new ServusMessage { Modul = mod, CallBackID = cbID, Authfunc = func }; return(internalServusMsg); }
public static ServusMessage createServusMessage(string gID, bool er, ErrorType erT, string erM) { ServusMessage internalServusMsg = new ServusMessage { Error = er, ErrorType = erT, ErrorMessage = erM, GameID = gID }; return(internalServusMsg); }
public static ServusMessage createServusMessage(Modulename mod, bool er, ErrorType erT, string erM) { ServusMessage internalServusMsg = new ServusMessage { Error = er, ErrorType = erT, ErrorMessage = erM, Modul = mod }; return(internalServusMsg); }
public static ServusMessage CreateServusMessageLogin(string email, string pw) { ServusMessage internalServusMsg = new ServusMessage { Modul = Modulename.AuthSelf, Authfunc = AuthFunctions.AuthLogin }; internalServusMsg.ValueSelfAuth = new ServusLogin_Self(); internalServusMsg.ValueSelfAuth.Email = email; internalServusMsg.ValueSelfAuth.Password = pw; return(internalServusMsg); }
private void LoginViaOnly(ServusLogin_Only loginData) { ServusMessage msg = ServusProtobufBasicFactory.createServusMessage(Modulename.AuthOnly, AuthFunctions.AuthLogin); msg.ValueOnlyAuth = loginData; _connection.SendMessage(msg); sleepModifier(500); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.True(_receivedEvents[0].ValueBool); Assert.False(_receivedEvents[0].Error); _receivedEvents.Clear(); }
public static ServusMessage CreateServusMessageLogin(string fbId, string token) { ServusMessage internalServusMsg = new ServusMessage { Modul = Modulename.AuthFb, Authfunc = AuthFunctions.AuthLogin, ValueFBAuth = new ServusLogin_FB { FbId = fbId, Token = token } }; return(internalServusMsg); }
internal void _internalClient_recieveMessage(ServusMessage message) { if (message.Modul == Modulename.AuthSelf) { if (message.Error == true) { HandleErrorMessage(message); } else { HandleNormalMessage(message); } } }
public static ServusMessage CreateServusMessageRegister(string email, string pw, string nickname) { ServusMessage internalServusMsg = new ServusMessage { Modul = Modulename.AuthSelf, Authfunc = AuthFunctions.AuthRegister }; internalServusMsg.ValueSelfAuth = new ServusLogin_Self(); internalServusMsg.ValueSelfAuth.Email = email; internalServusMsg.ValueSelfAuth.Password = pw; internalServusMsg.ValueSelfAuth.Nickname = nickname; return(internalServusMsg); }
private ServusLogin_Only RegisterOnly() { ServusMessage msg = ServusProtobufBasicFactory.createServusMessage(Modulename.AuthOnly, AuthFunctions.AuthRegister); msg.ValueString = "Dummy"; _connection.SendMessage(msg); sleepModifier(500); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.True(_receivedEvents[0].ValueOnlyAuth.Id > 0); Assert.False(_receivedEvents[0].Error); ServusLogin_Only returnVal = _receivedEvents[0].ValueOnlyAuth; _receivedEvents.Clear(); return(returnVal); }
private void HandleErrorMessage(ServusMessage message) { /// TDB Check if special handling for each message necessary... switch (message.Authfunc) { case AuthFunctions.AuthLogin: changeServerStateStatus(EmailLoginStates.LoginError); break; case AuthFunctions.AuthRegister: changeServerStateStatus(EmailLoginStates.LoginError); break; default: break; } }
private void HandleNormalMessage(ServusMessage message) { switch (message.Authfunc) { case AuthFunctions.AuthLogin: handleReciveMessage_Login(message.ValueBool); break; case AuthFunctions.AuthRegister: _settings.ServerUserid = message.ValueInt; this.ReSaveSettings(); Login(); break; default: break; } }
public void TestServerSimpleNoAuth() { Connect(); _receivedEvents = new List <ServusMessage>(); _connection.RecieveMessage += (ServusMessage m) => { _receivedEvents.Add(m); }; ServusMessage msg = ServusProtobufBasicFactory.createServusMessage(Modulename.Unknown, BasicFunctions.BasicUnkown); _connection.SendMessage(msg); sleepModifier(500); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.Equal(_receivedEvents[0].ErrorType, ErrorType.ErrorNoAuth); Assert.True(_receivedEvents[0].Error); _receivedEvents.Clear(); Disconnect(); }
private void HandleNormalAuthMessage(ServusMessage message) { switch (message.Authfunc) { case AuthFunctions.AuthLogin: if (message.ValueFBAuthResp.LoginSucessful) { Settings.Autologin = true; this.ReSaveSettings(); ChangeServerStateStatus(FbStates.LoginComplete); break; } switch (message.ValueFBAuthResp.Reason) { case FB_REASONS.IdNotMatchedToToken: ChangeServerStateStatus(FbStates.LoginError); break; case FB_REASONS.IdNotFound: Register(); break; default: ChangeServerStateStatus(FbStates.LoginError); break; } break; case AuthFunctions.AuthRegister: Settings.FbToken = message.ValueFBAuth.Token; Settings.ServerUserid = message.ValueFBAuth.FbId; if (CheckLoginData()) { this.ReSaveSettings(); Login(); } break; default: ChangeServerStateStatus(FbStates.LoginError); break; } }
public void HandleNormalUserDataMessage(ServusMessage message) { switch (message.Authfunc) { case AuthFunctions.AuthPicture: if (message.ValueUDataPicture.ValueBytes.IsEmpty && message.ValueUDataPicture.Reason == USERDATA_REASONS.NoPic) { ChangeServerStateStatus(FbStates.InitialDataComplete); /// TDB Default pic... break; } Fbuserdata.Picture = message.ValueUDataPicture.ValueBytes.ToArray <byte>(); ChangeServerStateStatus(FbStates.InitialDataComplete); break; default: break; } }
public void TestServerTestJoinQueueError() { Connect(); _receivedEvents = new List <ServusMessage>(); _connection.RecieveMessage += (ServusMessage m) => { _receivedEvents.Add(m); }; ServusLogin_Only obj = RegisterOnly(); LoginViaOnly(obj); ServusMessage msg = ServusProtobufBasicFactory.createServusMessage(Modulename.Queue, QueueFunctions.QueueUnkown); _connection.SendMessage(msg); sleepModifier(500); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.Equal(_receivedEvents[0].ErrorType, ErrorType.ErrorWrongmethod); Assert.True(_receivedEvents[0].Error); Disconnect(); }
public void TestServerTestEchoGameWrongGameId() { Connect(); _receivedEvents = new List <ServusMessage>(); _connection.RecieveMessage += (ServusMessage m) => { _receivedEvents.Add(m); }; string gameId = JoinQueue(); gameId += "A"; ServusMessage msg = ServusProtobufBasicFactory.createEchoGameMessage(Modulename.Directgame, TestGameFunctions.TgEcho, gameId); _connection.SendMessage(msg); sleepModifier(500); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.True(_receivedEvents[0].Error); Assert.Equal(_receivedEvents[0].ErrorType, ErrorType.ErrorNoGameFound); Disconnect(); }
public void TestServerTestModuleLoginModulCallbackId() { Connect(); _receivedEvents = new List <ServusMessage>(); _connection.RecieveMessage += (ServusMessage m) => { _receivedEvents.Add(m); }; ServusMessage msg = ServusProtobufBasicFactory.createServusMessage(Modulename.AuthOnly, AuthFunctions.AuthRegister); msg.ValueString = "Dummy"; msg.CallBackID = 123456789L; _connection.SendMessage(msg); sleepModifier(500); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.True(_receivedEvents[0].ValueOnlyAuth.Id > 0); Assert.False(_receivedEvents[0].Error); Assert.Equal(123456789L, _receivedEvents[0].CallBackID); _receivedEvents.Clear(); Disconnect(); }
public void TestServerTestEchoGame(int countStringLength, int sleepTime) { Connect(); _receivedEvents = new List <ServusMessage>(); _connection.RecieveMessage += (ServusMessage m) => { _receivedEvents.Add(m); }; string gameId = JoinQueue(); string strToSend = RandomString(countStringLength); ServusMessage msg = ServusProtobufBasicFactory.createEchoGameMessage(Modulename.Directgame, TestGameFunctions.TgEcho, gameId); msg.ValueString = strToSend; _connection.SendMessage(msg); sleepModifier(sleepTime); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.False(_receivedEvents[0].Error); Assert.Equal(strToSend, _receivedEvents[0].ValueString); Assert.Equal(gameId, _receivedEvents[0].GameID); Disconnect(); }
public void TestServerJoinloginViaOnlyWrongKey() { Connect(); _receivedEvents = new List <ServusMessage>(); _connection.RecieveMessage += (ServusMessage m) => { _receivedEvents.Add(m); }; ServusLogin_Only obj = RegisterOnly(); obj.Key = 12345; ServusMessage msg = ServusProtobufBasicFactory.createServusMessage(Modulename.AuthOnly, AuthFunctions.AuthLogin); msg.ValueOnlyAuth = obj; _connection.SendMessage(msg); sleepModifier(500); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.False(_receivedEvents[0].ValueBool); Assert.False(_receivedEvents[0].Error); _receivedEvents.Clear(); Disconnect(); }
//[InlineData(100000000, 10000)] --> Changes needed on Elix side public void TestServerTestModuleSendData(int countStringLength, int sleepTime) { Connect(); _receivedEvents = new List <ServusMessage>(); _connection.RecieveMessage += (ServusMessage m) => { _receivedEvents.Add(m); }; ServusLogin_Only obj = RegisterOnly(); LoginViaOnly(obj); string strToSend = RandomString(countStringLength); ServusMessage msg = ServusProtobufBasicFactory.createServusMessage(Modulename.TestEcho, BasicFunctions.BasicEcho); msg.ValueString = strToSend; _connection.SendMessage(msg); sleepModifier(sleepTime); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.False(_receivedEvents[0].ValueBool); Assert.False(_receivedEvents[0].Error); Assert.Equal(strToSend, _receivedEvents[0].ValueString); Disconnect(); }
public void TestServerTestModuleTestModulCallbackId() { Connect(); _receivedEvents = new List <ServusMessage>(); _connection.RecieveMessage += (ServusMessage m) => { _receivedEvents.Add(m); }; ServusLogin_Only obj = RegisterOnly(); LoginViaOnly(obj); string strToSend = RandomString(10000); ServusMessage msg = ServusProtobufBasicFactory.createServusMessage(Modulename.TestEcho, BasicFunctions.BasicEcho); msg.CallBackID = 123456789L; msg.ValueString = strToSend; _connection.SendMessage(msg); sleepModifier(100); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.False(_receivedEvents[0].Error); Assert.Equal(strToSend, _receivedEvents[0].ValueString); Assert.Equal(123456789L, _receivedEvents[0].CallBackID); Disconnect(); }
public void TestServerTestEchoTwoGameMultiple(int countStringLength, int sleepTime) { Connect(); _receivedEvents = new List <ServusMessage>(); _connection.RecieveMessage += (ServusMessage m) => { _receivedEvents.Add(m); }; string gameId = JoinQueue(); ServusMessage msg = ServusProtobufBasicFactory.createServusMessage(Modulename.Queue, QueueFunctions.QueueJoin); msg.ValueString = "testGame_1p"; _connection.SendMessage(msg); sleepModifier(500); Assert.Equal(3, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.Equal(typeof(ServusMessage), _receivedEvents[1].GetType()); Assert.Equal(typeof(ServusMessage), _receivedEvents[2].GetType()); Assert.False(_receivedEvents[0].Error); Assert.False(_receivedEvents[1].Error); Assert.False(_receivedEvents[2].Error); Assert.Equal(QueueFunctions.QueueGameid, _receivedEvents[1].Queuefunc); Assert.True(null != _receivedEvents[1].ValueString); Assert.Equal(TestGameFunctions.TgBegin, _receivedEvents[0].TestGamefunc); Assert.Equal("Dummy", _receivedEvents[0].ValueString); Assert.Equal(QueueFunctions.QueueJoin, _receivedEvents[2].Queuefunc); string gameId2 = _receivedEvents[1].ValueString; _receivedEvents.Clear(); ///First Gameid string strToSend = RandomString(countStringLength); msg = ServusProtobufBasicFactory.createEchoGameMessage(Modulename.Directgame, TestGameFunctions.TgEcho, gameId); msg.ValueString = strToSend; _connection.SendMessage(msg); sleepModifier(sleepTime); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.False(_receivedEvents[0].Error); Assert.Equal(strToSend, _receivedEvents[0].ValueString); Assert.Equal(gameId, _receivedEvents[0].GameID); _receivedEvents.Clear(); /// Second Gameid strToSend = RandomString(countStringLength); msg = ServusProtobufBasicFactory.createEchoGameMessage(Modulename.Directgame, TestGameFunctions.TgEcho, gameId2); msg.ValueString = strToSend; _connection.SendMessage(msg); sleepModifier(sleepTime); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.False(_receivedEvents[0].Error); Assert.Equal(strToSend, _receivedEvents[0].ValueString); Assert.Equal(gameId2, _receivedEvents[0].GameID); /// First again _receivedEvents.Clear(); strToSend = RandomString(countStringLength); msg = ServusProtobufBasicFactory.createEchoGameMessage(Modulename.Directgame, TestGameFunctions.TgEcho, gameId); msg.ValueString = strToSend; _connection.SendMessage(msg); sleepModifier(sleepTime); Assert.Equal(1, _receivedEvents.Count); Assert.Equal(typeof(ServusMessage), _receivedEvents[0].GetType()); Assert.False(_receivedEvents[0].Error); Assert.Equal(strToSend, _receivedEvents[0].ValueString); Assert.Equal(gameId, _receivedEvents[0].GameID); Disconnect(); }