func (s *Session) Send(reply *Response) (err error) { defer func() { if x := recover(); x != nil { err = errors.New("Session.Send: " + fmt.Sprintln(x)) } }() return cfg.GetServer(s.SerId).Client().Send("Connect.Push", PushRequest{ Uniq: s.ToUint(), Reply: reply, }) }
func (s *Session) Mutex(f func()) { var lockreply LockResponse err := cfg.GetServer(s.SerId).Client().Call("Connect.Lock", LockRequest{ Uniq: s.ToUint(), Hold: cfg.SelfId, }, &lockreply) if err != nil { return } s = lockreply.Session.Sync() defer func() { var unlockreply Response unlockreply.Session = s cfg.GetServer(s.SerId).Client().Send("Connect.Unlock", UnlockRequest{ Uniq: s.ToUint(), Reply: &unlockreply, }) }() f() }