Search in sources :

Example 1 with MapMessage

use of com.generallycloud.baseio.container.jms.MapMessage in project baseio by generallycloud.

the class FixedMessageConsumer method onReceive.

@Override
public void onReceive(Message message) {
    int msgType = message.getMsgType();
    if (Message.TYPE_MAP == msgType) {
        MapMessage m = (MapMessage) message;
        String eventName = m.getParameter("eventName");
        OnMappedMessage onMessage = onMappedMessages.get(eventName);
        if (onMessage == null) {
            return;
        }
        onMessage.onReceive(m);
    } else if (Message.TYPE_MAP_BYTE == msgType) {
        MapByteMessage m = (MapByteMessage) message;
        String eventName = m.getParameter("eventName");
        OnMappedMessage onMessage = onMappedMessages.get(eventName);
        if (onMessage == null) {
            return;
        }
        onMessage.onReceive(m);
    } else if (Message.TYPE_TEXT == msgType) {
        if (onTextMessage != null) {
            onTextMessage.onReceive((TextMessage) message);
        }
    } else if (Message.TYPE_TEXT_BYTE == msgType) {
        if (onTextByteMessage != null) {
            onTextByteMessage.onReceive((TextByteMessage) message);
        }
    } else if (Message.TYPE_ERROR == msgType) {
        if (onErrorMessage != null) {
            onErrorMessage.onReceive((ErrorMessage) message);
        }
    } else if (Message.TYPE_NULL == msgType) {
        if (onNullMessage != null) {
            onNullMessage.onReceive((NullMessage) message);
        }
    }
}
Also used : TextByteMessage(com.generallycloud.baseio.container.jms.TextByteMessage) NullMessage(com.generallycloud.baseio.container.jms.NullMessage) MapMessage(com.generallycloud.baseio.container.jms.MapMessage) MapByteMessage(com.generallycloud.baseio.container.jms.MapByteMessage)

Example 2 with MapMessage

use of com.generallycloud.baseio.container.jms.MapMessage in project baseio by generallycloud.

the class RTPClient method setRTPHandle.

public void setRTPHandle(final RTPHandle handle) throws RTPException {
    if (this.handle != null) {
        return;
    }
    this.consumer.listen("invite", new OnMappedMessage() {

        @Override
        public void onReceive(MapMessage message) {
            handle.onInvite(RTPClient.this, message);
        }
    });
    this.consumer.listen("invite-reply", new OnMappedMessage() {

        @Override
        public void onReceive(MapMessage message) {
            handle.onInviteReplyed(RTPClient.this, message);
        }
    });
    this.consumer.listen("break", new OnMappedMessage() {

        @Override
        public void onReceive(MapMessage message) {
            handle.onBreak(RTPClient.this, message);
        }
    });
    this.handle = handle;
    try {
        this.consumer.receive(null);
    } catch (MQException e) {
        throw new RTPException(e);
    }
}
Also used : MQException(com.generallycloud.baseio.container.jms.MQException) OnMappedMessage(com.generallycloud.baseio.container.jms.client.impl.OnMappedMessage) MapMessage(com.generallycloud.baseio.container.jms.MapMessage) RTPException(com.generallycloud.baseio.container.rtp.RTPException)

Example 3 with MapMessage

use of com.generallycloud.baseio.container.jms.MapMessage in project baseio by generallycloud.

the class RTPClient method leaveRoom.

public boolean leaveRoom() throws RTPException {
    try {
        Authority authority = session.getAuthority();
        if (authority == null) {
            throw new RTPException("not login");
        }
        ProtobaseFuture future = session.request(RTPJoinRoomServlet.SERVICE_NAME, roomId);
        this.handle.onBreak(this, new MapMessage("", authority.getUuid()));
        return JmsUtil.isTrue(future);
    } catch (IOException e) {
        throw new RTPException(e.getMessage(), e);
    }
}
Also used : ProtobaseFuture(com.generallycloud.baseio.codec.protobase.future.ProtobaseFuture) Authority(com.generallycloud.baseio.container.authority.Authority) RTPException(com.generallycloud.baseio.container.rtp.RTPException) MapMessage(com.generallycloud.baseio.container.jms.MapMessage) IOException(java.io.IOException)

Example 4 with MapMessage

use of com.generallycloud.baseio.container.jms.MapMessage in project baseio by generallycloud.

the class RTPClient method inviteCustomer.

public void inviteCustomer(String inviteUsername) throws RTPException {
    if (roomId == null) {
        throw new RTPException("none roomId,create room first");
    }
    Authority authority = session.getAuthority();
    if (authority == null) {
        throw new RTPException("not login");
    }
    MapMessage message = new MapMessage("msgId", inviteUsername);
    message.put("eventName", "invite");
    message.put("roomId", roomId);
    message.put("inviteUsername", authority.getUsername());
    try {
        producer.offer(message);
    } catch (MQException e) {
        throw new RTPException(e);
    }
    this.inviteUsername = inviteUsername;
}
Also used : MQException(com.generallycloud.baseio.container.jms.MQException) Authority(com.generallycloud.baseio.container.authority.Authority) RTPException(com.generallycloud.baseio.container.rtp.RTPException) MapMessage(com.generallycloud.baseio.container.jms.MapMessage)

Example 5 with MapMessage

use of com.generallycloud.baseio.container.jms.MapMessage in project baseio by generallycloud.

the class RTPClient method inviteReply.

public void inviteReply(String inviteUsername, int markinterval, long currentMark, int groupSize) throws RTPException {
    MapMessage message = new MapMessage("msgId", inviteUsername);
    message.put("eventName", "invite-reply");
    message.put(MARK_INTERVAL, markinterval);
    message.put(CURRENT_MARK, currentMark);
    message.put(GROUP_SIZE, groupSize);
    try {
        producer.offer(message);
    } catch (MQException e) {
        throw new RTPException(e);
    }
    this.inviteUsername = inviteUsername;
}
Also used : MQException(com.generallycloud.baseio.container.jms.MQException) MapMessage(com.generallycloud.baseio.container.jms.MapMessage) RTPException(com.generallycloud.baseio.container.rtp.RTPException)

Aggregations

MapMessage (com.generallycloud.baseio.container.jms.MapMessage)7 RTPException (com.generallycloud.baseio.container.rtp.RTPException)4 MQException (com.generallycloud.baseio.container.jms.MQException)3 Authority (com.generallycloud.baseio.container.authority.Authority)2 JSONObject (com.alibaba.fastjson.JSONObject)1 ParamedProtobaseProtocolFactory (com.generallycloud.baseio.codec.protobase.ParamedProtobaseProtocolFactory)1 ProtobaseFuture (com.generallycloud.baseio.codec.protobase.future.ProtobaseFuture)1 LoggerSocketSEListener (com.generallycloud.baseio.component.LoggerSocketSEListener)1 NioSocketChannelContext (com.generallycloud.baseio.component.NioSocketChannelContext)1 Parameters (com.generallycloud.baseio.component.Parameters)1 SocketChannelContext (com.generallycloud.baseio.component.SocketChannelContext)1 ServerConfiguration (com.generallycloud.baseio.configuration.ServerConfiguration)1 SocketChannelConnector (com.generallycloud.baseio.connector.SocketChannelConnector)1 FixedSession (com.generallycloud.baseio.container.FixedSession)1 SimpleIoEventHandle (com.generallycloud.baseio.container.SimpleIoEventHandle)1 MapByteMessage (com.generallycloud.baseio.container.jms.MapByteMessage)1 NullMessage (com.generallycloud.baseio.container.jms.NullMessage)1 TextByteMessage (com.generallycloud.baseio.container.jms.TextByteMessage)1 TextMessage (com.generallycloud.baseio.container.jms.TextMessage)1 MessageProducer (com.generallycloud.baseio.container.jms.client.MessageProducer)1