public int TelCodeVerify(int czoneID, int croleID, int telCode) { int result = (int)ESpreadState.Fail; try { ISpreadService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { try { result = kuaFuService.TelCodeVerify(_ClientInfo.ServerId, czoneID, croleID, telCode); } catch (System.Exception ex) { ResetKuaFuService(); } } } catch (System.Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(result); }
public bool SpreadVip(int pzoneID, int proleID, int czoneID, int croleID) { bool result = false; try { ISpreadService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { try { result = kuaFuService.SpreadVip(pzoneID, proleID, czoneID, croleID); } catch (System.Exception ex) { ResetKuaFuService(); } } } catch (System.Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(result); }
public void TimerProc(object sender, EventArgs e) { try { string uri = this._CoreInterface.GetRuntimeVariable("SpreadUri", null); if (this._RemoteServiceUri != uri) { this._RemoteServiceUri = uri; } ISpreadService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { if (this._ClientInfo.ClientId > 0) { AsyncDataItem[] items = kuaFuService.GetClientCacheItems(this._ClientInfo.ServerId); if (items != null && items.Length > 0) { this.ExecuteEventCallBackAsync(items); } } } this.CheckSpreadData(); } catch (Exception ex) { this.ResetKuaFuService(); } }
public int CheckVerifyCode(string cuserID, int czoneID, int croleID, int pzoneID, int proleID, int isVip, int isLevel) { int result = (int)ESpreadState.Fail; try { ISpreadService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { try { result = kuaFuService.CheckVerifyCode(_ClientInfo.ServerId, cuserID, czoneID, croleID, pzoneID, proleID, isVip, isLevel); } catch (System.Exception ex) { ResetKuaFuService(); } } } catch (System.Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(result); }
public void TimerProc(object sender, EventArgs e) { try { string uri = _CoreInterface.GetRuntimeVariable(RuntimeVariableNames.SpreadUri, null); if (_RemoteServiceUri != uri) { _RemoteServiceUri = uri; } ISpreadService kuaFuService = GetKuaFuService(); if (null != kuaFuService) { if (_ClientInfo.ClientId > 0) { //同步数据 AsyncDataItem[] items = kuaFuService.GetClientCacheItems(_ClientInfo.ServerId); if (null != items && items.Length > 0) { ExecuteEventCallBackAsync(items); } } } CheckSpreadData(); } catch (System.Exception ex) { ResetKuaFuService(); } }
public int TelCodeVerify(int czoneID, int croleID, int telCode) { int result = -1; try { ISpreadService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { result = kuaFuService.TelCodeVerify(this._ClientInfo.ServerId, czoneID, croleID, telCode); } catch (Exception ex) { this.ResetKuaFuService(); } } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(result); }
public int CheckVerifyCode(string cuserID, int czoneID, int croleID, int pzoneID, int proleID, int isVip, int isLevel) { int result = -1; try { ISpreadService kuaFuService = this.GetKuaFuService(false); if (null != kuaFuService) { try { result = kuaFuService.CheckVerifyCode(this._ClientInfo.ServerId, cuserID, czoneID, croleID, pzoneID, proleID, isVip, isLevel); } catch (Exception ex) { this.ResetKuaFuService(); } } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(result); }
private void ResetKuaFuService() { _RemoteServiceUri = _CoreInterface.GetRuntimeVariable(RuntimeVariableNames.SpreadUri, null); lock (_Mutex) { _KuaFuService = null; } }
private ISpreadService GetKuaFuService(bool noWait = false) { ISpreadService kuaFuService = null; int clientId = -1; try { lock (_Mutex) { if (string.IsNullOrEmpty(_RemoteServiceUri)) { return(null); } if (null == _KuaFuService && noWait) { return(null); } } lock (_RemotingMutex) { if (_KuaFuService == null) { kuaFuService = (ISpreadService)Activator.GetObject(typeof(ISpreadService), _RemoteServiceUri); if (null == kuaFuService) { return(null); } } else { kuaFuService = _KuaFuService; } clientId = kuaFuService.InitializeClient(this, _ClientInfo); if (null != kuaFuService && (clientId != _ClientInfo.ClientId || _KuaFuService != kuaFuService)) { lock (_Mutex) { _KuaFuService = kuaFuService; _ClientInfo.ClientId = clientId; return(kuaFuService); } } return(_KuaFuService); } } catch (System.Exception ex) { ResetKuaFuService(); LogManager.WriteExceptionUseCache(ex.ToString()); } return(null); }
public int SpreadSign(int zoneID, int roleID) { int result; try { lock (_Mutex) { KFSpreadData data; //如果取到数据,证明已经注册说了 if (_RoleId2KFSpreadDataDict.TryGetValue(roleID, out data)) { return(0); } ISpreadService kuaFuService = GetKuaFuService(); if (null == kuaFuService) { return(StdErrorCode.Error_Server_Not_Registed); } try { result = kuaFuService.SpreadSign(_ClientInfo.ServerId, zoneID, roleID); if (result > 0) { KFSpreadData newData = new KFSpreadData(); newData.ServerID = _ClientInfo.ServerId; newData.ZoneID = zoneID; newData.RoleID = roleID; _RoleId2KFSpreadDataDict.TryAdd(roleID, newData); } } catch (System.Exception ex) { ResetKuaFuService(); } } } catch (System.Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(StdErrorCode.Error_Success); }
public int[] SpreadCount(int zoneID, int roleID) { int[] array = new int[3]; int[] counts = array; lock (this._Mutex) { KFSpreadData data; if (this._RoleId2KFSpreadDataDict.TryGetValue(roleID, out data)) { data.UpdateLogtime(); return(new int[] { data.CountRole, data.CountVip, data.CountLevel }); } ISpreadService kuaFuService = this.GetKuaFuService(false); if (null == kuaFuService) { return(counts); } try { counts = kuaFuService.SpreadCount(this._ClientInfo.ServerId, zoneID, roleID); if (counts != null && counts.Length == 3) { KFSpreadData newData = new KFSpreadData(); newData.ServerID = this._ClientInfo.ServerId; newData.ZoneID = zoneID; newData.RoleID = roleID; newData.CountRole = counts[0]; newData.CountVip = counts[1]; newData.CountLevel = counts[2]; this._RoleId2KFSpreadDataDict.TryAdd(roleID, newData); } } catch (Exception ex) { this.ResetKuaFuService(); } } return(counts); }
public int SpreadSign(int zoneID, int roleID) { try { lock (this._Mutex) { KFSpreadData data; if (this._RoleId2KFSpreadDataDict.TryGetValue(roleID, out data)) { return(0); } ISpreadService kuaFuService = this.GetKuaFuService(false); if (null == kuaFuService) { return(-11001); } try { int result = kuaFuService.SpreadSign(this._ClientInfo.ServerId, zoneID, roleID); if (result > 0) { KFSpreadData newData = new KFSpreadData(); newData.ServerID = this._ClientInfo.ServerId; newData.ZoneID = zoneID; newData.RoleID = roleID; this._RoleId2KFSpreadDataDict.TryAdd(roleID, newData); } } catch (Exception ex) { this.ResetKuaFuService(); } } } catch (Exception ex) { LogManager.WriteExceptionUseCache(ex.ToString()); } return(1); }
public Worker(ILogger <Worker> logger, IServerService serverService, ISpreadService spreadService) { isInitState = true; _configurationManager = new ConfigurationManager(); _logger = logger; _spreadService = spreadService; exisitingClients = new List <ClientData>(); var connected = _spreadService.ConnectToSpread(); if (connected) { var spreadGroupName = _spreadService.JoinSpreadGroup(); Console.WriteLine($"Joined the group {spreadGroupName} ..."); Console.WriteLine("Preparing message listener\'s ..."); _spreadService._spreadConnection.OnMembershipMessage += _spreadConnection_OnMembershipMessage; _spreadService._spreadConnection.OnRegularMessage += _spreadConnection_OnRegularMessage; } else { Console.WriteLine("Cannot connect to the deamon ...."); } string actorName = "server"; Globals.groupSize = 2; Console.Title = actorName; try { localChatActor = Globals.mainActorSystem.ActorOf(Props.Create <RegisterActor>(_spreadService), "RegisterActor"); } catch (Exception ex) { Console.WriteLine(ex); } }
public RegisterActor(ISpreadService service) { spreadService = service; }