JAVA API

The JAVA Server API allows java application to send real-time messages via the PushFYI server. The JAVA API allow requests to be made synchronously.

JAVA Server API has 2 main functions. In this documentation, we will examine the API usage and some of the best practices.

PushFYI - Interface Class

The PushFYI class is the entry point for any application to send receive real-time messages via the PushFYI WebSocket Gateway. This class wraps all the necessary methods to send real-time events.

This is not a singleton class and you can create more than one objects of this class.

Argument List:

SN parameters note
1 appsecret This parameter identifies your App when it connects to PushFYI. Since PushFYI can serve real-time messages to many apps simultaneously. This field allows PushFYI to distinguish between Apps, so that real-time messages from one App do not mix up with another App. The value of appsecret parameter is in UUID format. e.g. 123e4567-e89b-12d3-a456-426655440000
2 address URL of your pushfyi instance. e.g. 10.0.0.101
3 isSecure Boolean variable for secure/plain text connection.

Code Sample:


                                                      using libpushfyi;



    public class MainClass
    {
        static void Main(string[] args)
        {
		/* 
 * initialize the connection 
 * @param app_secret
 * @param cluster_address
 * 
 */
            PushFYI p = new PushFYI("<your appsecret key>","<your pushfyi ip address>","<boolean variable for secure/plain text connection>");
        }
    }
    

publish(channel, data)

The publish method allows a JAVA application to publish a realtime message synchronously on a given data channel. PushFYI data channels are logical names to which realtime messages are sent to.

This method allows you to send a single message on a given data channel.

Parameter List:

SN parameters note
1 channel The logical name of the data channel associated with an event.
2 data Data type string as template argument.

Code Sample:

  
    public class MainClass
    {
        static void Main(string[] args)
        {
		/* 
 * initialize the connection 
 * @param app_secret
 * @param cluster_address
 * 
 */
            Pushfyi pushfyi = new Pushfyi("<your appsecret key>","<your pushfyi ip address>","<boolean variable for secure/plain text connection>");
            string data="Hello pushfyi";
			/*
 * publish message on single channel in Realtime
 * @param channel
 * @param data 
 */
            int successResult=pushfyi.publish("java_channel", data);
		    System.out.println("result is "+successResult);
        }
    }