예제 #1
0
func (self *DummyPlug) WriteMessageQueue(request mqtt.Message) {
	switch request.GetType() {
	case mqtt.PACKET_TYPE_CONNECT:
	case mqtt.PACKET_TYPE_CONNACK:
	case mqtt.PACKET_TYPE_PUBLISH:
		self.message <- request
	case mqtt.PACKET_TYPE_DISCONNECT:
		self.message <- request
	case mqtt.PACKET_TYPE_SUBSCRIBE:
	case mqtt.PACKET_TYPE_SUBACK:
	case mqtt.PACKET_TYPE_UNSUBSCRIBE:
	case mqtt.PACKET_TYPE_UNSUBACK:
	case mqtt.PACKET_TYPE_PINGRESP:
	case mqtt.PACKET_TYPE_PINGREQ:
	case mqtt.PACKET_TYPE_PUBACK:
		self.message <- request
	case mqtt.PACKET_TYPE_PUBREC:
		self.message <- request
	case mqtt.PACKET_TYPE_PUBREL:
		self.message <- request
	case mqtt.PACKET_TYPE_PUBCOMP:
		self.message <- request
	default:
		return
	}
}
예제 #2
0
// Without lock
func (self *MmuxConnection) writeMessageQueue(request mqtt.Message) {
	// TODO: これそもそもmuxがあったらもうdummyか普通のか、ぐらいなような気が
	_, is_dummy := (*self.Connection).(*DummyPlug)
	if self.Connection == nil {
		// already disconnected
		return
	} else if is_dummy {
		if request.GetType() == mqtt.PACKET_TYPE_PUBLISH {
			self.OfflineQueue = append(self.OfflineQueue, request)
		}
	}

	(*self.Connection).WriteMessageQueue(request)
}