Package net.sf.jml.protocol.msnslp

Examples of net.sf.jml.protocol.msnslp.MsnslpRequest


        this.slpMessage = slpMessage;
    }

    @Override
  protected void parseP2PBody(ByteBuffer buffer) {
        slpMessage = new MsnslpRequest();
        if (!slpMessage.readFromBuffer(buffer)) {
            slpMessage = new MsnslpResponse();
            slpMessage.readFromBuffer(buffer);
        }
    }
View Full Code Here


                getSlpMessage().getClass().getName());
            return;
        }

    // Get Slp message
        MsnslpRequest msnslpRequest = (MsnslpRequest) getSlpMessage();

        // Get a properties
        String method = msnslpRequest.getRequestMethod();
        String guid_euf = msnslpRequest.getBodys().getProperty(KEY_GUID_EUF);
        String context = msnslpRequest.getBodys().getProperty(KEY_CONTEXT);

        int sessionIdInt =
            getSlpMessage().getBodys().getIntProperty("SessionID", -1);
        String sessionId = String.valueOf(sessionIdInt);

        if (method != null && method.equals(METHOD_INVITE) &&
            msnslpRequest.getCSeq() == 0 &&
            guid_euf != null && guid_euf.equals(GUID_EUF) &&
          context != null)
        {
            context = context.substring(0,context.length()-1);
View Full Code Here

            return sendFile(switchboard, email, file);
    }

    private MsnFileTransfer sendFile(MsnSwitchboard switchboard, Email email, File file)
    {
        MsnslpRequest req = new MsnslpRequest();
        MsnFileInviteMessage invite = new MsnFileInviteMessage()
        {
            protected void receivedResponse(MsnSession session, MsnIncomingMessage response)
            {
                if((getOffset() + getCurrentLength()) < getTotalLength())
                {
                    binaryHeader.rewind();

                    setOffset(getCurrentLength());
                    long currLen = getTotalLength() - getCurrentLength();

                    if(currLen > MsnP2PDataMessage.MAX_DATA_LENGTH)
                        setCurrentLength(MsnP2PDataMessage.MAX_DATA_LENGTH);
                    else
                        setCurrentLength((int)currLen);

                    OutgoingMSG[] outgoingOkMessages = toOutgoingMsg(
                        session.getMessenger().getActualMsnProtocol());
                    for (OutgoingMSG outgoingOkMessage : outgoingOkMessages)
                    {
                        session.sendSynchronousMessage(outgoingOkMessage);
                    }
                }
            }
        };
        invite.setSlpMessage(req);
        int lastRandomIdentifier = NumberUtils.getIntRandom();

        // Set the destination for the message (the MsnObject creator)
        invite.setP2PDest(email.getEmailAddress());

        // Set the binary Header
        invite.setIdentifier(MsnP2PBaseIdGenerator.getInstance().getNextId());
        invite.setFlag(MsnP2PMessage.FLAG_OLD_NONE);
        invite.setField7(lastRandomIdentifier);
        invite.setField8(0);
        invite.setField9(0);

        // Set body
        req.setRequestMethod(MsnFileInviteMessage.METHOD_INVITE);
        req.setRequestURI("MSNMSGR:" + email.getEmailAddress());
        req.setTo("<msnmsgr:" + email.getEmailAddress() + ">");
        req.setFrom("<msnmsgr:" +
                    session.getMessenger().getOwner().getEmail().getEmailAddress() + ">");
        req.setVia(
            "MSNSLP/1.0/TLP ;branch=" + generateNewCallId());
        req.setCSeq(0);
        req.setCallId(generateNewCallId());
        req.setMaxForwards(0);
        req.setContentType("application/x-msnmsgr-sessionreqbody");

        StringHolder body = new StringHolder();
    body.setProperty(MsnFileInviteMessage.KEY_GUID_EUF,
                 MsnFileInviteMessage.GUID_EUF);
    body.setProperty("SessionID", lastRandomIdentifier);
    body.setProperty("AppID", 2);
        try
        {
            body.setProperty(MsnP2PInvitationMessage.KEY_CONTEXT,
                MsnFileContextParser.getEncodedContext(file));
        }
        catch (UnsupportedEncodingException ex)
        {
            logger.error("", ex);
        }

    req.setBody(body.toString() +
            JmlConstants.LINE_SEPARATOR + "\0");

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

        if(slpMessageLength > MsnP2PDataMessage.MAX_DATA_LENGTH)
        {
            invite.setCurrentLength(MsnP2PDataMessage.MAX_DATA_LENGTH);
View Full Code Here

    transferSessionId = NumberUtils.getIntRandom();
    lastRandomIdentifier = NumberUtils.getIntRandom();
    callId = generateNewCallId();
   
    // Create an invitation message
    MsnslpRequest req = new MsnslpRequest();
    MsnP2PInvitationMessage msg = new MsnP2PInvitationMessage();
    msg.setSlpMessage(req);

    // Set the destination for the message (the MsnObject creator)
    msg.setP2PDest(creator.getEmailAddress());

    // Set the binary Header
    msg.setSessionId(0);
    msg.setIdentifier(getNextIdentifier());
    msg.setFlag(0);
    msg.setField7(lastRandomIdentifier);
    msg.setField8(0);
    msg.setField9(0);
   
    // Body
    req.setRequestMethod(MsnP2PInvitationMessage.METHOD_INVITE);
    req.setRequestURI("MSNMSGR:" + creator.getEmailAddress());
    req.setTo("<msnmsgr:" + creator.getEmailAddress() + ">");
    req.setFrom("<msnmsgr:" +
            messenger.getOwner().getEmail().getEmailAddress() + ">");
    req.setVia("MSNSLP/1.0/TLP ;branch=" + callId);
    req.setCSeq(0);
    req.setCallId(callId);
    req.setMaxForwards(0);
    req.setContentType("application/x-msnmsgr-sessionreqbody");
    StringHolder body = new StringHolder();
    body.setProperty(MsnP2PInvitationMessage.KEY_GUID_EUF,
                 MsnP2PInvitationMessage.GUID_EUF);
    body.setProperty("SessionID", transferSessionId);
    body.setProperty("AppID", 1);
    body.setProperty(MsnP2PInvitationMessage.KEY_CONTEXT,
                     StringUtils.encodeBase64(msnObject.toString()));
    req.setBody(body.toString() +
            JmlConstants.LINE_SEPARATOR + "\0");

    // Get the size of the message to be setted
    int slpMessageLength = Charset.encodeAsByteArray(req.toString()).length;
    msg.setTotalLength(slpMessageLength);
    msg.setCurrentLength(slpMessageLength);
   
    // Binary Footer
    msg.setAppId(0);
View Full Code Here

  /**
   * Send the bye Message.
   */
  private void sendP2PByeMessage() {

    MsnslpRequest req = new MsnslpRequest();
    MsnP2PByeMessage bye = new MsnP2PByeMessage();
    bye.setSlpMessage(req);
    lastRandomIdentifier = NumberUtils.getIntRandom();

    // Set the destination for the message (the MsnObject creator)
    bye.setP2PDest(creator.getEmailAddress());
   
    // Set the binary Header
    bye.setSessionId(0);
    bye.setIdentifier(getNextIdentifier());
    bye.setFlag(MsnP2PMessage.FLAG_BYE);
    bye.setField7(lastRandomIdentifier);
    bye.setField8(0);
    bye.setField9(0);
   
    // Set body
    req.setRequestMethod(MsnP2PByeMessage.METHOD_BYE);
    req.setRequestURI("MSNMSGR:" + creator.getEmailAddress());
    req.setTo("<msnmsgr:" + creator.getEmailAddress() + ">");
    req.setFrom("<msnmsgr:" +
            messenger.getOwner().getEmail().getEmailAddress() + ">");
    req.setVia(
      "MSNSLP/1.0/TLP ;branch=" + callId);
    req.setCSeq(0);
    req.setCallId(callId);
    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);
   
    // Set footer
    bye.setAppId(0);
View Full Code Here

    // Check if it is an invitation for a direct connection
    else if (message instanceof MsnP2PInvitationMessage) {
     
      // Check that it is an invitation for direct connection
      MsnP2PInvitationMessage invite = (MsnP2PInvitationMessage) message;
      MsnslpRequest inviteRequest = (MsnslpRequest) invite.getSlpMessage();
      if (inviteRequest.getContentType().equals(
          "application/x-msnmsgr-transreqbody")) {

        // Check that the SessionID and the CallID are the same
        int sessionId = inviteRequest.getBodys().getIntProperty("SessionID");
        String callId = inviteRequest.getCallId();
        if (sessionId == transferSessionId && callId.equals(callId)) {

          // Send an ACK for the message
          sendP2PAck(message, false);
         
View Full Code Here

TOP

Related Classes of net.sf.jml.protocol.msnslp.MsnslpRequest

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.