Пример #1
0
  public void sendDeny(MsnP2PSlpMessage msg) {
    MsnslpRequest msnslpRequest = (MsnslpRequest) msg.getSlpMessage();
    MsnslpResponse okSlpMessage = new MsnslpResponse();
    okSlpMessage.setStatusCode(405);
    okSlpMessage.setReasonPhrase("Not supported");
    okSlpMessage.setTo(msnslpRequest.getFrom());
    okSlpMessage.setFrom(msnslpRequest.getTo());
    okSlpMessage.setVia(msnslpRequest.getVia());
    okSlpMessage.setCSeq(msnslpRequest.getCSeq() + 1);
    okSlpMessage.setCallId(msnslpRequest.getCallId());
    okSlpMessage.setMaxForwards(msnslpRequest.getMaxForwards());
    okSlpMessage.setContentType(msnslpRequest.getContentType());

    StringHolder body = new StringHolder();
    body.setProperty("SessionID", fileTransfer.getID());
    okSlpMessage.setBody(body.toString() + JmlConstants.LINE_SEPARATOR + "\0");

    int okSlpMessageLength = Charset.encodeAsByteArray(okSlpMessage.toString()).length;

    MsnP2PSlpMessage okMessage = new MsnP2PSlpMessage();
    okMessage.setSlpMessage(okSlpMessage);
    okMessage.setIdentifier(getNextIdentifier());
    okMessage.setTotalLength(okSlpMessageLength);
    okMessage.setCurrentLength(okSlpMessageLength);
    okMessage.setField7(NumberUtils.getIntRandom());
    okMessage.setP2PDest(fileTransfer.getEmail().getEmailAddress());

    OutgoingMSG[] outgoingOkMessages =
        okMessage.toOutgoingMsg(fileTransfer.getSession().getMessenger().getActualMsnProtocol());
    for (OutgoingMSG outgoingOkMessage : outgoingOkMessages) {
      fileTransfer.getSession().sendSynchronousMessage(outgoingOkMessage);
    }
  }
Пример #2
0
  private void sendBye() {
    MsnslpRequest req = new MsnslpRequest();
    MsnFileByeMessage bye = new MsnFileByeMessage();
    bye.setSlpMessage(req);
    int lastRandomIdentifier = NumberUtils.getIntRandom();

    // Set the destination for the message (the MsnObject creator)
    bye.setP2PDest(fileTransfer.getEmail().getEmailAddress());

    // Set the binary Header
    bye.setSessionId(Integer.parseInt(fileTransfer.getID()));
    bye.setIdentifier(getNextIdentifier());
    bye.setFlag(MsnP2PMessage.FLAG_OLD_NONE);
    bye.setField7(lastRandomIdentifier);
    bye.setField8(0);
    bye.setField9(0);

    // Set body
    req.setRequestMethod(MsnP2PByeMessage.METHOD_BYE);
    req.setRequestURI(
        "MSNMSGR:"
            + fileTransfer.getSession().getMessenger().getOwner().getEmail().getEmailAddress());
    req.setTo("<msnmsgr:" + fileTransfer.getEmail().getEmailAddress() + ">");
    req.setFrom(
        "<msnmsgr:"
            + fileTransfer.getSession().getMessenger().getOwner().getEmail().getEmailAddress()
            + ">");
    req.setVia("MSNSLP/1.0/TLP ;branch={A0D624A6-6C0C-4283-A9E0-BC97B4B46D32}");
    req.setCSeq(0);
    req.setCallId(fileTransfer.getReqMessage().getSlpMessage().getCallId());
    req.setMaxForwards(0);
    req.setContentType("application/x-msnmsgr-sessionclosebody");
    req.setBody(JmlConstants.LINE_SEPARATOR + "\0");

    // Get the size of the message to be setted
    int slpMessageLength = Charset.encodeAsByteArray(req.toString()).length;
    bye.setTotalLength(slpMessageLength);
    bye.setCurrentLength(slpMessageLength);

    OutgoingMSG[] outgoingOkMessages =
        bye.toOutgoingMsg(fileTransfer.getSession().getMessenger().getActualMsnProtocol());
    for (OutgoingMSG outgoingOkMessage : outgoingOkMessages) {
      if (switchboard != null) switchboard.send(outgoingOkMessage);
      else fileTransfer.getSession().sendAsynchronousMessage(outgoingOkMessage);
    }
  }