func (a *agent) WriteMsg(msg interface{}) { if a.gate.Processor != nil { data, err := a.gate.Processor.Marshal(msg) if err != nil { log.Error("marshal message %v error: %v", reflect.TypeOf(msg), err) return } err = a.conn.WriteMsg(data...) if err != nil { log.Error("write message %v error: %v", reflect.TypeOf(msg), err) return } } }
func destroy(s *service) { defer func() { if r := recover(); r != nil { if conf.Env.StackBufLen > 0 { buf := make([]byte, conf.Env.StackBufLen) l := runtime.Stack(buf, false) log.Error("%v: %s", r, buf[:l]) } else { log.Error("%v", r) } } }() s.si.OnDestroy() }
func (a *agent) OnClose() { if a.gate.AgentChanRPC != nil { err := a.gate.AgentChanRPC.Open(0).Call0("CloseAgent", a) if err != nil { log.Error("chanrpc error: %v", err) } } }
func (t *Timer) Cb() { defer func() { t.cb = nil if r := recover(); r != nil { if conf.Env.StackBufLen > 0 { buf := make([]byte, conf.Env.StackBufLen) l := runtime.Stack(buf, false) log.Error("%v: %s", r, buf[:l]) } else { log.Error("%v", r) } } }() if t.cb != nil { t.cb() } }
func (s *Skeleton) Run(closeSig chan bool) { for { select { case <-closeSig: s.chanRPCServer.Close() return case ci := <-s.chanRPCServer.ChanCall: err := s.chanRPCServer.Exec(ci) if err != nil { log.Error("%v", err) } case t := <-s.dispatcher.ChanTimer: t.Cb() } } }
func (c *Client) call(ci *CallInfo, block bool) (err error) { defer func() { if r := recover(); r != nil { log.Error("panic: %#v", r) err = r.(error) } }() if block { c.s.ChanCall <- ci } else { select { case c.s.ChanCall <- ci: default: err = errors.New("chanrpc channel full") } } return }