From 819b49248b59b02a229d8c31712ccb782590b527 Mon Sep 17 00:00:00 2001 From: tanghai Date: Mon, 31 Oct 2016 16:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AASession=20b?= =?UTF-8?q?ug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Component/NetworkComponent.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Unity/Assets/Scripts/Component/NetworkComponent.cs b/Unity/Assets/Scripts/Component/NetworkComponent.cs index 345f4bca..212aff71 100644 --- a/Unity/Assets/Scripts/Component/NetworkComponent.cs +++ b/Unity/Assets/Scripts/Component/NetworkComponent.cs @@ -71,16 +71,11 @@ namespace Model Session session = new Session(this.GetOwner(), channel); channel.ErrorCallback += (c, e) => { this.Remove(session.Id); }; - this.Add(session); + this.sessions.Add(session.Id, session); + this.AddToAddressDict(session); } } - - private void Add(Session session) - { - this.sessions.Add(session.Id, session); - this.AddToAddressDict(session); - } - + private void AddToAddressDict(Session session) { Session s; @@ -123,15 +118,15 @@ namespace Model return session; } - session = this.GetNew(address); + session = this.Create(address); this.AddToAddressDict(session); return session; } /// - /// 创建一个新Session,不保存到地址缓存中 + /// 创建一个新Session /// - public Session GetNew(string address) + public Session Create(string address) { string[] ss = address.Split(':'); int port = int.Parse(ss[1]); @@ -139,6 +134,7 @@ namespace Model AChannel channel = this.Service.ConnectChannel(host, port); Session session = new Session(this.GetOwner(), channel); channel.ErrorCallback += (c, e) => { this.Remove(session.Id); }; + this.sessions.Add(session.Id, session); return session; } -- GitLab