func (self *ApnsConnection) sendMessage(msg *entry.Message) error { //将当前的msg强制设置为当前conn的id作为标识 msg.ProcessId = self.connectionId err, packet := msg.Encode() if nil != err { return err } length, sendErr := self.conn.Write(packet) if nil != err || length != len(packet) { log.Warn("CONNECTION|SEND MESSAGE|FAIL|%s", err) } else { log.Debug("CONNECTION|SEND MESSAGE|SUCC") } return sendErr }
func (self *ApnsConnection) sendMessage(msg *entry.Message) error { //将当前的msg强制设置为当前conn的id作为标识 msg.ProcessId = self.connectionId err, packet := msg.Encode() if nil != err { return err } //单链接重发3次 var sendErr error for i := 0; i < 3; i++ { length, err := self.conn.Write(packet) if nil != err || length != len(packet) { sendErr = err log.Printf("CONNECTION|SEND MESSAGE|FAIL|%s|tryCount:%d|%s\n", err, i, msg) } else { log.Printf("CONNECTION|SEND MESSAGE|SUCC|tryCount:%d|%s\n", i, msg) break } } return sendErr }