private async Task RunSession(FSSession session, ushort index, int count, bool needNetty) { var account = "account" + index; var password = "******"; var playerName = "player" + index; try { session.SetDestroyedHandler((sender, e) => { NLogger.Info($"session:{session.GetId()} destroyed!"); }); //注册账号 var playerprx = session.UncheckedCast(IPlayerCoPrxHelper.uncheckedCast, IPlayerCoPrxHelper.ice_staticId()); var ret = await playerprx.RegOrLoginReqAsync(account, password); NLogger.Debug("RegOrLoginReqAsync ok:" + account + ", result=" + ret); var zoneprx = session.UncheckedCast(IZoneCoPrxHelper.uncheckedCast, IZoneCoPrxHelper.ice_staticId()); await zoneprx.TestApiReqAsync(); NLogger.Debug("TestApiReqAsync ok:" + account); for (int i = 0; i < 20; ++i) { var str = Console.In.ReadLine(); switch (str) { case "1": await zoneprx.TestApiReq2Async(); break; case "13": await zoneprx.TestApiReq3Async(); break; } } NLogger.Info($"{account} playerPrx end!"); } catch (Ice.Exception ex) { NLogger.Error(account + ":" + ex.Message); } catch (System.Exception e) { NLogger.Error(account + ":" + e.ToString()); } finally { //session.Destory(); } }
public async static Task <bool> Connect(string ip, int port) { try { session = await client.CreateSession(ip, port); return(true); } catch (System.Exception e) { logger.Error("net connect:" + e.ToString()); return(false); } }