提交 819b4924 编写于 作者: T tanghai

修复一个Session bug

上级 052ff131
...@@ -71,16 +71,11 @@ namespace Model ...@@ -71,16 +71,11 @@ namespace Model
Session session = new Session(this.GetOwner<Scene>(), channel); Session session = new Session(this.GetOwner<Scene>(), channel);
channel.ErrorCallback += (c, e) => { this.Remove(session.Id); }; 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) private void AddToAddressDict(Session session)
{ {
Session s; Session s;
...@@ -123,15 +118,15 @@ namespace Model ...@@ -123,15 +118,15 @@ namespace Model
return session; return session;
} }
session = this.GetNew(address); session = this.Create(address);
this.AddToAddressDict(session); this.AddToAddressDict(session);
return session; return session;
} }
/// <summary> /// <summary>
/// 创建一个新Session,不保存到地址缓存中 /// 创建一个新Session
/// </summary> /// </summary>
public Session GetNew(string address) public Session Create(string address)
{ {
string[] ss = address.Split(':'); string[] ss = address.Split(':');
int port = int.Parse(ss[1]); int port = int.Parse(ss[1]);
...@@ -139,6 +134,7 @@ namespace Model ...@@ -139,6 +134,7 @@ namespace Model
AChannel channel = this.Service.ConnectChannel(host, port); AChannel channel = this.Service.ConnectChannel(host, port);
Session session = new Session(this.GetOwner<Scene>(), channel); Session session = new Session(this.GetOwner<Scene>(), channel);
channel.ErrorCallback += (c, e) => { this.Remove(session.Id); }; channel.ErrorCallback += (c, e) => { this.Remove(session.Id); };
this.sessions.Add(session.Id, session);
return session; return session;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册