Package com.sissi.protocol.message

Examples of com.sissi.protocol.message.Message


   * @see com.sissi.persistent.impl.PersistentMessage#write(com.sissi.protocol.Element)
   */
  @Override
  public Map<String, Object> write(Element element) {
    Map<String, Object> entity = super.write(element);
    Message message = Message.class.cast(element);
    if (message.delay()) {
      entity.put(Dictionary.FIELD_SOURCE, message.getDelay().getFrom());
      entity.put(Dictionary.FIELD_DELAY, message.getDelay().getStamp());
      entity.put(Dictionary.FIELD_FROM, super.jidBuilder.build(element.getFrom()).asStringWithBare());
    } else {
      entity.put(Dictionary.FIELD_SOURCE, this.relationMucMapping.mapping(super.jidBuilder.build(element.getFrom())).jid().asString());
    }
    return entity;
View Full Code Here


   *
   * @see com.sissi.persistent.impl.PersistentMessage#read(java.util.Map)
   */
  @Override
  public Message read(Map<String, Object> element) {
    Message message = Message.class.cast(super.read(element, new Message()));
    return message.muc(new XUser().invite(new Invite().reason(super.toString(element, Dictionary.FIELD_REASON)).continued(super.toString(element, Dictionary.FIELD_CONTINUE)).setFrom(element.get(Dictionary.FIELD_INVITE).toString()))).delay(super.delay(element, message)).request(Boolean.valueOf(element.get(Dictionary.FIELD_ACK).toString()));
  }
View Full Code Here

   * @see com.sissi.persistent.impl.PersistentProtocol#write(com.sissi.protocol.Element)
   */
  @Override
  public Map<String, Object> write(Element element) {
    Map<String, Object> entity = super.write(element);
    Message message = Message.class.cast(element);
    entity.put(Dictionary.FIELD_ACK, !message.request());
    entity.put(Dictionary.FIELD_THREAD, message.thread());
    entity.put(Dictionary.FIELD_BODY, message.content() ? message.getBody().getText() : null);
    return entity;
  }
View Full Code Here

   *
   * @see com.sissi.persistent.PersistentElement#read(java.util.Map)
   */
  @Override
  public Message read(Map<String, Object> element) {
    Message message = Message.class.cast(super.read(element, new Message()));
    return message.body(super.toString(element, Dictionary.FIELD_BODY)).delay(this.delay(element, message)).setThread(super.toString(element, Dictionary.FIELD_THREAD)).request(Boolean.valueOf(element.get(Dictionary.FIELD_ACK).toString()));
  }
View Full Code Here

    this.body = new Body(content);
  }

  @Override
  public boolean input(JIDContext context, Protocol protocol) {
    return super.resources(context.jid(), true).isEmpty() ? true : super.findOne(context.jid(), true, true).write(new Message().body(this.body).setType(MessageType.HEADLINE).setFrom(context.domain())).write(Stream.closeGraceFully()).close();
  }
View Full Code Here

    this.subject = subject;
  }

  @Override
  public boolean input(JIDContext context, Protocol protocol) {
    Message message = new Message().noneThread().subject(this.subject).setFrom(protocol.parent().getTo()).cast(Message.class).data(this.register.register(protocol.cast(Register.class).findField(XData.NAME, XData.class), new XData().setType(XDataType.FORM)).add(new XInput(XFieldType.HIDDEN.toString(), null, RequestConfig.GROUP.toString(), protocol.parent().getTo())).add(new XInput(XFieldType.HIDDEN.toString(), null, RequestConfig.JID.toString(), context.jid().asStringWithBare())));
    for (Relation relation : this.relationContext.myRelations(super.build(protocol.parent().getTo()), ItemRole.MODERATOR.toString())) {
      super.findOne(super.build(relation.jid()), true).write(message);
    }
    return true;
  }
View Full Code Here

  @Override
  public boolean input(JIDContext context, Protocol protocol) {
    XUser user = this.extracter.extract(protocol.cast(Owner.class).getX(), new XUser()).cast(XUser.class);
    if (user.contain()) {
      JID group = super.build(protocol.parent().getTo());
      Protocol message = new Message().noneThread().muc(user).setType(MessageType.GROUPCHAT).setFrom(group);
      for (JID jid : super.whoSubscribedMe(group)) {
        super.findOne(jid, true).write(message);
      }
    }
    return true;
View Full Code Here

   *
   * @see com.sissi.pipeline.Input#input(com.sissi.context.JIDContext, com.sissi.protocol.Protocol)
   */
  @Override
  public boolean input(JIDContext context, Protocol protocol) {
    Message message = Message.class.cast(protocol);
    return (message.getBody() != null && message.getBody().content()) || message.received();
  }
View Full Code Here

  @Override
  public AffiliationBroadcast broadcast(JID group, Room room, MucItem item, JIDContext invoker) {
    // 岗位限制则发出加入邀请
    if (!room.allowed(this.jidBuilder.build(item.getJid()), RoomConfig.AFFILIATIONALLOW)) {
      // Message.to = group, Invite.to = item.jid
      this.proxy.input(invoker, new Message().muc(new XUser().invite(new Invite().setTo(item.getJid()))).setTo(group));
    }
    return this;
  }
View Full Code Here

  @Override
  public boolean input(JIDContext context, Protocol protocol) {
    JID group = super.build(protocol.getTo());
    String subject = room.build(group).pull(Dictionary.FIELD_SUBJECT, String.class);
    if (subject != null) {
      context.write(new Message().noneThread().subject(new Subject(subject)).setType(MessageType.GROUPCHAT).setFrom(group.resource(super.ourRelation(context.jid(), group).name())));
    }
    return true;
  }
View Full Code Here

TOP

Related Classes of com.sissi.protocol.message.Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.