public bool SendLoginSucc(IPlayerInfo playerInfo, INetworkChannel channel) { if (_state == RoomState.Running) { var sessionObjects = _contexts.session.serverSessionObjects; var msg = LoginSuccMessage.Allocate(); msg.GameRule = (int)sessionObjects.GameRule; _contexts.session.commonSession.RoomInfo.ToLoginSuccMsg(msg); msg.Camp = playerInfo.Camp; FreeArgs.Trigger(FreeTriggerConstant.PRELOAD_RESOURCE, new TempUnit("roomInfo", new ObjectUnit(msg)), new TempUnit("playerInfo", new ObjectUnit(playerInfo))); channel.SendReliable((int)EServer2ClientMessage.LoginSucc, msg); msg.ReleaseReference(); _logger.InfoFormat("player SendLoginSucc with name {0}", playerInfo.PlayerName); } return(true); }
public bool TryDivide(string fullCmd) { CommandName = fullCmd.Split(' ')[0].Trim(); ArgString = fullCmd.IndexOf(" ", StringComparison.Ordinal) == -1 ? "" : fullCmd.Substring(fullCmd.IndexOf(" ", StringComparison.Ordinal) + 1, fullCmd.Length - CommandName.Length - 1).Trim(); List <string> splitedParam = new List <string>(); SimpleArgs = ArgString.Split(' ').ToList(); if (ArgString == "") { return(false); } try { splitedParam.AddRange(ArgString.Split(' ')); foreach (var item in splitedParam) { if (Quote.Any(q => ContainsChar(q, item))) { throw new ArgumentException(); } } bool combined = true; foreach (var item in Quote) { for (int i = 0; i < splitedParam.Count - 1; i++) { string cur = splitedParam[i], next = splitedParam[i + 1]; if (cur.StartsWith(item) && !cur.EndsWith(item)) { combined = false; splitedParam[i] = cur + " " + next; splitedParam.Remove(next); if (splitedParam[i].EndsWith(item)) { combined = true; } i--; } } if (!combined) { throw new ArgumentException("Expect '" + item + "'."); } } string tmpKey = null, tmpValue; bool isLastKeyOrValue = false; splitedParam.Add("-"); foreach (var item in splitedParam) { tmpValue = null; if (item.StartsWith('-')) { if (tmpKey != null) { Switches.Add(tmpKey, tmpKey); } tmpKey = item.Remove(0, 1); isLastKeyOrValue = true; } else { foreach (var q in Quote) { tmpValue = tmpValue == null?item.Trim(q) : tmpValue.Trim(q); } if (!isLastKeyOrValue) { FreeArgs.Add(tmpValue); //throw new ArgumentException("Expect key."); } else { Args.Add(tmpKey, tmpValue); tmpKey = null; tmpValue = null; isLastKeyOrValue = false; } } } } catch (Exception ex) { Logger.Debug(ex.Message); return(false); } return(true); }