NCL Community Forum Index
  Home   Login   Register   Help   Memberlist   Search   NCL  

NCL Community Forum Index » SwiftNote (SMSJDK) Support » Setting up a transceiver
Post new topic  Reply to topic View previous topic :: View next topic 
Setting up a transceiver
PostPosted: Tue Oct 10, 2006 1:48 pm Reply with quote
Administrator
Site Admin
Joined: 11 Aug 2004
Posts: 237




A transceiver is a 2 way SMS connection to the SMSC. With provato you can setup a transceiver by setting the bind type in the Factory.properties file
Code:
myConnection.bindType=transceiver
and in your java application you can use the following:
Code:
Connection connection = Factory.getConnection("myConnection");
Receiver receiver = (Receiver)connection;
Transmitter transmitter = (Transmitter)connection;

An example of using a tranceiver from the API would be:
Code:

package ie.ncl.mms;

import ie.ncl.msg.*;

/*
 * (C) 2006 NCL Technologies (www.nclt.com). All rights reserved.
 */

public class TransceiverExample implements ReceiverListener, SenderListener
{
    static final String TEST_NUMBER="+353123456789";

    public boolean received(Receiver receiver, Exception ex, Message m)
    {
        // Called when a message has been received.
        if(m!=null)
            System.out.println("Received "+m);
        return true;
    }

    public void sent(Sender sender, Exception ex, Message m)
    {
        // Called when a message has been sent.
    }

    Connection swiftnoteConnection=null;

    public TransceiverExample() throws ConnectionException
    {
        swiftnoteConnection = Factory.getConnection("modem");

        ((Receiver)swiftnoteConnection).setReceiverListener(this);

        swiftnoteConnection.connect();
    }

    public void sendWithoutWaiting(String tel, String text) throws ConnectionException, MessageException
    {
        Message message = new TextMessage(new Address(tel),text);

        ((Sender)swiftnoteConnection).send(message,this);

        // Callback will be called
    }

    SyncSender syncSender = null;
    public void sendAndWait(String tel, String text) throws ConnectionException, MessageException
    {
        if(syncSender==null)
            syncSender = new SyncSender((Sender)swiftnoteConnection);
        Message message = new TextMessage(new Address(tel),text);
        syncSender.send(message);
    }

    public void close()
    {
        swiftnoteConnection.close();
    }

    public static void main(String args[]) throws ConnectionException, MessageException
    {
        TransceiverExample eg = new TransceiverExample();

        try
        {
        System.out.println("Sending one but no wait");
        eg.sendWithoutWaiting(TEST_NUMBER,"sent without waiting for response");
        System.out.println("Sending one and waiting");
        eg.sendAndWait(TEST_NUMBER,"Hello there how are you");
        System.out.println("Message sent");
        }
        finally
        {
            eg.close();
        }
    }

}

View user's profile Send private message

Setting up a transceiver
 NCL Community Forum Index » SwiftNote (SMSJDK) Support
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Post new topic  Reply to topic