Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Push Notification Client/Server

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Push Notification Client/Server

    Hello world, gotta few questions as I am totally new to java but I have lots of programming experience. I'm looking for some advice/expertise from an experienced java applet networking programmer.

    I need a way to notify my web-clients that new data is available on the server for download, but only while a "main" applet is running in the browser. I would like this to be in a library project (jarred and run as a separate applet) so I could possibly use it in my other projects. I am curious as to whether or not this is a good idea as I don't know if the browser controls applet firewall security for the applets it runs or if they have their own access rights. It most likely depends on how advanced the firewall in use on the client system is. From my experience, some firewalls treat listening/sending socket & thread permissions differently.

    My purpose for such a project is thus:

    A.) Nothing I know of provides client/server event notification for applets/web-pages
    B.) This would save communications bandwidth compared to client request polling.
    C.) This would increase communication latency compared to client request polling.
    E.) This would improve browser responsiveness compared to request polling.
    D.) This would save many server processing cycles.

    The potential savings are incalculable but it only makes sense that if you don't have to send a request, analyze it and respond to it on both ends every second for every connected client that the savings will allow more usage of the server.

    I see five good reasons to create such a project. Perhaps someone out there knows how to use the HTTP Keep Alive content header and that would be better and more secure than a listening socket. This is acceptable as long as the browser does not show that it is in a "loading data" state with progress/status indicators but I do believe this would require a lofty amount of server side work and I am not using JSP.

    "Transferring data from..." This annoys the "%*$ out of me. It is useful for most situations but it totally takes the seamless out of integration when it comes to real-time data applications. The user already knows that data is loading and I don't want the status bar being stolen from the main applet by the browser or the browser appearing to be "frozen" in a data request state to novice users.

    It makes no sense to me as to why W3C, NetScape/Mozilla, Microsoft never implemented something like this. Then again maybe they spend more time/resources buying patents and litigating than they do actually being creative. Heaven forbid Google should come up with something like it if they already haven't. My privacy is being invaded enough between them and facebook.

    So what do you think?


  2. #2
    Junior Member
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Push Notification Client/Server

    Ok so HTTP Push is just something I never heard of but quite resembles the content header keep alive idea i had...Push technology - Wikipedia, the free encyclopedia

  3. #3
    Junior Member
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Push Notification Client/Server

    There are too many technology implementation discrepancies regarding post #2 for it to be a platform independent technology. IE moving to a new server, supporting multiple browsers, or distributing a commercial product would be too much of a hassle. I suppose my code will just have to test the socket connection on first use by the client and inform them that they need to add a firewall exception if it fails to succeed. The real problem is that it might not be an issue of a firewall permissions at all.

  4. #4
    Junior Member
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Push Notification Client/Server

    It would be more than great if SUN/ORACLE/Microsoft/Free Software Foundation/Apple/Apache/MIT/UC Berkely whatever would implement something like this for us free to all governments corporations and private entities!!! A simple server that resembles the ping server. A platform localized service saves system resources (ports, memory, storage) for applications that use the same technology. Logically any remote service would only need to send at most three fields of type long IN NETWORK BYTE ORDER to perform any API push notification. This is secure! The possibility to send/receive string data by a service like this is a security risk.

    The application to use the service would register a random, currently unused, 32-Bit long application identifier to distinguish which application gets what message. This would be the first field of type long in a remote notification push. To ensure platform independence, applications (better, language api) receive notifications via open file handles. The application is responsible for notifying the remote service of how it can be contacted on the local system.

    It is very important for application identifiers to be random! This will allow security policies to be enforced should some hacker/script kiddie decide to guess at random/sequential order application control which will have a defined set of api!! Of course anyone who can monitor network traffic who also has intimate knowledge of specific application sets and the api therein will possibly be able to exert control over a system, with proper heuristic analysis tools which don't to this day exist. This is the price you pay for using ANY open standard technology over an unsecured network.

    The second field of type long would specify some type of application defined action to be performed, and the third field would be any associative data that may be relevant to the action. I find this type of service would be acceptable to run on my machine or even my servers by any application that has executable permissions, provided proper logging facilities and policy enforcement controls are in place by the service. It would not be possible to do a buffer overflow attack because the input buffer length is previously defined. As far as information security goes, if you are hyper paranoid you might as well write your own implementation. I see no potential for remote command execution that has not been previously defined.

    The registered application receives three three parameters upon successful data reception: ASSUMED data transfer originating I.P., The second input field of type long (action), The third input field of type long (extended action info). At most this service returns one of two possible answers to the ASSUMED originating IP: NOTIFICATION ACCEPTED, NOTIFICATION DENIED. For security reasons extended error information should never be remotely transmitted to a possible attacker by a public service. Error information is the bread and butter of finding out how things you shouldn't know about work. If an application does not return true from a notification, system policy defines how the DENIAL will be interpreted.

    This is the concept of a workaround for the current JVM security models, where code signing is necessary to open a listening port on a computer. However the concept I propose, proves to be technology that all modern operating systems are lacking. I would rather be notified by an update service that updates are available then having to call them every day and ask, I am also sure that with all the possibilities of individuals downloading data, this would save considerable resources for many corporations, private parties and institutions.

    Therefore I propose a new world wide standard that I call: The Unified Application Push Notification Service (UAPNS) Not to be confused with a Private Application Push Notification Service, that has no standard at all!

    My Name is Triston J. Taylor, and I dare to be a Worldwide Technology Innovator. How about yourself?

  5. #5
    Junior Member
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Push Notification Client/Server

    OK people here are my "untested" Server classes to be run in the browser. Java Security says this stuff must be jarred and signed + permitted by system policy. The license is provided here in this post and only this post:
    This code and this concept is FREE for ANYONE to do whatever IS DESIRABLE with IT. Only IT (the code and concept) may NOT be proposed to or granted Copyright to any individual or entity in an effort to PREVENT OR SUE anyone from employing similar technology in their projects and or products.
    - Best damned free software license smokin' (BDF-SLS License as DEFINED HERE)

    First a callback interface:

    package web.site.push;
     
    import java.net.InetAddress;
     
    public interface Pushable {
     
    	public void ServiceActivated(Listener service);
    	public void ServiceTerminated(Listener service);
     
    	public void DebugMessage(Listener service, String error);
    	public void ConnectionRefused(Listener service, InetAddress from);
    	public void Pushed(Listener service, InetAddress from, int operation, int flags);
     
    }

    This next class is the heart and soul of the 'daemon' which accepts connections from any 'registered' remote address. Local interface is registered automatically. Connection and data transfer processing is handled sequentially by a single thread that runs separate from the "user-space." This is the intended design to prevent race conditions from multiple remote sources (web servers) who intend to push notifications independently to a web client (this server). Once a notification has been processed, run errant, or denied, the remote connection is closed and the daemon returns processing the next incoming connection, provided that it has not been instructed to die. This "one-shot" technique is employed for the advantage of local concurrency and CGI programs who are themselves generally "one-shot" processes.

    package web.site.push;
     
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.InetAddress;
    import java.net.ServerSocket;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.nio.ByteBuffer;
     
    public class Listener implements Runnable {
     
    	private int localPort = 0;
    	private Pushable owner;
    	private ServerSocket com;
    	private Thread daemon;
    	private InetAddress[] remoteClients;
    	private static int listeners = 0;
    	private int myRef = 0;
    	private String myName = "";
     
    	private boolean acceptable = false; // Accept another connection?
     
    	public Listener(Pushable callback, String name) {
     
    		owner = callback;
     
    		// Set default accept from local host
    		remoteClients = new InetAddress[1];
    		try {remoteClients[0] = InetAddress.getLocalHost();} catch (UnknownHostException ex) {}
     
    		daemon = new Thread(this);	// Declared here to allow access to IsAlive()
     
    		ref();
     
    		if (name == null || name.equals("")) { name = "" + myRef;}
    		myName = name;
     
    	}
     
    	public void run() {
     
    		owner.ServiceActivated(this);
     
    		while (acceptable) {
     
    			try {
    				HandleConnection( com.accept() );
    			}
     
    			catch (IOException ex) { // System error....
    				acceptable = false;	 // BREAK NEXT LOOP
    				owner.DebugMessage(this, ex.toString()); // Report
    			}
     
    		}
     
    		try {
     
    			com.close();
     
    		} catch (IOException ex) {
     
    			owner.DebugMessage(this, ex.toString());
     
    		}
     
    		owner.ServiceTerminated(this);
     
    	}
     
    	private void ref() {
    		listeners++;
    		myRef = listeners;
    	}
     
    	public int ID() {
    		return myRef;
    	}
     
    	public String Name() {
    		return myName;
    	}
     
    	public InetAddress LocalAddress() {
    		return com.getInetAddress();
    	}
     
    	public int LocalPort() {
    		return com.getLocalPort();
    	}
     
    	public boolean Listen(int port) {
     
    		// attempt to listen on all local interfaces
    		return Listen(null, port);
     
    	}
     
    	public boolean Listen(InetAddress localAddress, int port) {
     
    		if (daemon.isAlive()) { return true; }
     
    		localPort = port;
     
    		try {
     
    		  com = new ServerSocket(localPort, 1024, localAddress);
     
    		}
     
    		catch (SecurityException se) {
     
    			owner.DebugMessage(this, se.toString());
    			return false;
     
    		}
     
    		catch (IOException ex) {
     
    			owner.DebugMessage(this, ex.toString());
    			return false;
     
    		}
     
    		daemon.start (	);
     
    		return daemon.isAlive();
     
    	}
     
    	public void Die() {
     
    		acceptable = false;
     
    	}
     
    	public boolean Listening() {
     
    		return daemon.isAlive();
     
    	}
     
    	private void HandleConnection(Socket remote) {
     
    		InputStream is;
    		OutputStream os;
    		byte[] in = new byte[8];
    		ByteBuffer input = ByteBuffer.wrap(in);
     
    		if (remote != null) {
     
    			try {
     
    				InetAddress fromAddress = remote.getInetAddress();
    				os = remote.getOutputStream();
    				is = remote.getInputStream();
     
    				if (ConnectionPermitted(fromAddress)) {
     
    					os.write(6);  // ASCII ACK
    					os.write(22); // Synchronus idle
    					os.flush();
     
    					int count = 0;
    					int loop = 0;
     
    					while(true) {
     
    						count = is.available();
     
    						if (count == 8) {
    							break;
    						} else if (count > 8) { throw new IOException("Input past expected end of stream from: " + DescribeAddress(fromAddress)); }
     
    						try { Thread.sleep(10); } catch (InterruptedException ex) { owner.DebugMessage(this, "Idle synchronization sleep interrupted."); }
     
    						loop++;
     
    						if (loop > 500) {
    							// 5 second timeout or 500 repitions exceeded
    							//os.write(22); // Synchronus idle
    							os.write(21); // Not acknowledged (timed out)
    							os.write(16); // Data link escape
    							os.flush();
    							throw new IOException("Synchronus idle timeout waiting for: " + DescribeAddress(fromAddress));
    						}
    					}
     
    					is.read(in, 0, 8);
     
    					int op = input.getInt();
    					int ex = input.getInt();
     
    					owner.Pushed(this, fromAddress, op, ex);
     
    					os.write(6);  // Acknowledged
    					os.write(16); // Data link escape
    					os.flush();
     
    				} else {
     
    					// Connection not permitted.
    					os.write(21); // Request not Acknowledged
    					os.write(16); // Data link escape
    					os.flush();
     
    				}
     
    			} catch (IOException ex) { owner.DebugMessage(this, ex.getMessage()); }
     
    			try {remote.close();} catch (IOException ex) { owner.DebugMessage(this, ex.toString()); }
     
    		}
     
    	}
     
    	public boolean ConnectionPermitted(InetAddress remote) {
     
    		for (int i = 0; i < remoteClients.length; i++) {
     
    			if (remoteClients[i].equals(remote)) {
     
    				return true;
     
    			}
     
    		}
     
    		owner.ConnectionRefused(this, remote);
     
    		return false;
     
    	}
     
    	public static String DescribeAddress(InetAddress sa) {
    		return sa.getHostName() + " (" + sa.getHostAddress() + ")";
    	}
     
     
    	public void AcceptClient(InetAddress client) {
    		if (client == null) { return; }
    		if (ConnectionPermitted(client)) { return; }
    		InetAddress[] copy = remoteClients.clone();
    		remoteClients = new InetAddress[copy.length+1];
    		System.arraycopy(copy, 0, remoteClients, 0, copy.length);
    		remoteClients[remoteClients.length - 1] = client;
    	}
     
    	public void DenyClient(InetAddress client) {
    		if (client == null || remoteClients[0].equals(client) || remoteClients.length == 1) { return; }
    		if (! ConnectionPermitted(client)) { return; }
    		InetAddress[] newcopy = new InetAddress[remoteClients.length - 1];
    		int offset = 0;
    		for (int i = 0; i < remoteClients.length; i++) {
    			if (! remoteClients[i].equals(client)) {
    				newcopy[i+offset] = remoteClients[i];
    			} else {
    				offset = -1;
    			}
    		}
    		remoteClients = newcopy.clone();
    	}
     
    }

    As I stated in the beginning of this thread I basically have ZERO experience with java programming so there may be some stuff in this code that doesn't work properly, specifically the call to Thread.Sleep and the method I used to ensure that all data was available before the desired 8 bytes were read into the buffer. If you know much about socket programming and it looks shady to you, please feel free to post a fix. I couldn't find any examples of a server that operates this way.

    Finally I provide the APPLET class which uses the NETSCAPE.JAR for Cross Browser LiveConnect Functionality. You must provide the MAYSCRIPT attribute to the applet's HTML definition or this code will fail you when attempting to get the browser window object or perform any callbacks from java to notify the "web client controller" scripts.

    Even though the Listener class supports adding and removing remote connection permissions at runtime this functionality is not extended to the browser by this class for security reasons. All acceptable connections must be defined in HTML before the class's "init" method is called by the browser. All of these classes should be considered "conceptual" although they might even work out of the box or with just a few minor code edits. By design an HTML document may define as many listeners as the system it runs on will support.

    Applet Code:


    package web.site.push;
    import java.applet.Applet;
    import java.net.InetAddress;
    import java.net.UnknownHostException;
    import netscape.javascript.*;
     
    public class Target extends Applet implements Pushable {
     
    	private JSObject window = null;
     
    	private String jsCallBackMethod = "onServerPush";
    	private String jsDebugMethod = "";
    	private String jsActivateMethod = "";
    	private String jsTerminateMethod = "";
    	private String jsRefusedConnectionMethod = "";
    	private String jsObjName = "";
    	private boolean useDebugging = false;
     
    	private int listenerPort = 1982;
    	private Listener listener = null;
     
    	@Override
    	public void init() {
     
    		// get the JSObject representing the applet's browser window.
    		window = JSObject.getWindow(this);
     
    		// get initial config params if present
    		String supplied = getParameter("onPush");
    		if (supplied.length() > 0) {
    			jsCallBackMethod = supplied;
    		}
     
    		supplied = getParameter("onDebug");
    		if (supplied.length() > 0) {
    			jsDebugMethod = supplied;
    			useDebugging = true;
    		}
     
    		supplied = getParameter("debugging");
    		if (supplied.equalsIgnoreCase("true") || supplied.equals("1")) {
    			useDebugging = true;
    		}
     
    		supplied = getParameter("onActivate");
    		if (supplied.length() > 0) {
    			jsActivateMethod = supplied;
    		}
     
    		supplied = getParameter("onTerminate");
    		if (supplied.length() > 0) {
    			jsTerminateMethod = supplied;
    		}
     
    		supplied = getParameter("onConnectionRefused");
    		if (supplied.length() > 0) {
    			jsRefusedConnectionMethod = supplied;
    		}
     
    		supplied = getParameter("LocalPort");
    		if(supplied.length() > 0) {
    			listenerPort = Integer.parseInt(supplied);
    		}
     
    		supplied = getParameter("Name");
    		if(supplied.length() > 0) {
    			jsObjName = supplied;
    		}
     
    		listener = new Listener(this, jsObjName);
     
    		supplied = getParameter("RemoteClients");
    		if (supplied.length() > 0) {
    			String[] clients = supplied.split("\\s+");
    			for (int i = 0; i < clients.length; i++) {
    				try {
    					listener.AcceptClient(InetAddress.getByName(clients[i]));
    				} catch (UnknownHostException ex) {
    					DebugMessage(listener, "Unknown Host: " + clients[i]);
    				}
    			}
    		}
     
    		listener.Listen(listenerPort);
     
    	}
     
    	public void Pushed(Listener service, InetAddress from, int operation, int intent) {
    		Object[] args = new Object[4];
    		args[0] = service.Name();
    		args[1] = from.getHostName();
    		args[2] = operation;
    		args[3] = intent;
    		window.call(jsCallBackMethod, args);
    	}
     
    	public int LocalPort() { return listenerPort; }
     
    	public void Terminate() {
    		listener.Die();
    	}
     
    	public boolean Active() {
    		return listener.Listening();
    	}
     
    	public void ConnectionRefused(Listener service, InetAddress from) {
     
    		if (jsRefusedConnectionMethod.length() > 0) {
    			Object[] args = new Object[3];
    			args[0] = service.Name();
    			args[1] = from.getHostName();
    			args[2] = from.getHostAddress();
    			window.call(jsRefusedConnectionMethod, args);
    		} else {
    			DebugMessage(service, "Connection Refused from: " + from.getHostName() + " (" + from.getHostAddress() + ")");
    		}
     
    	}
     
    	public void DebugMessage(Listener service, String msg) {
     
    		if (! useDebugging ) { return; }
     
    		if (jsDebugMethod.length() > 0) {
    			Object[] arg = new Object[2];
    			arg[0] = service.Name();
    			arg[1] = msg;
    			window.call(jsDebugMethod, arg);
    		} else {
    			System.err.println("Push Listener (" + service.Name() + "): " + msg);
    		}
     
    	}
     
    	public void ServiceTerminated(Listener service) {
    		if (jsTerminateMethod.length() > 0) {
    			Object[] arg = new Object[2];
    			arg[0] = service.Name();
    			arg[1] = "Service Terminated";
    			window.call(jsTerminateMethod, arg);
    		} else {
    			DebugMessage(service, "Service Terminated");
    		}
    	}
     
    	public void ServiceActivated(Listener service) {
    		if (jsActivateMethod.length() > 0) {
    			Object[] arg = new Object[2];
    			arg[0] = service.Name();
    			arg[1] = "Service Activated";
    			window.call(jsActivateMethod, arg);
    		} else {
    			DebugMessage(service, "Service Terminated");
    		}
    	}
     
    }

    Ok that's it for the web-client server! Hopefully my next post will contain a complete zipped working example of a client/server as well as a textual code listing of the client class as was presented here in this post with the above classes.

    According to my own specification, this is a:
    Private Application Push Notification Service
    Last edited by MistaWizurd; April 29th, 2011 at 02:04 PM. Reason: Line 183 of web.site.push.Listener (os.write(22);) was deprecated! The client expects only two bytes of status information.

  6. #6
    Junior Member
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Push Notification Client/Server

    Some quick LiveConnect Reference info for beginners NetSpade - Web Developer Heaven

    See this page for info on supplying and retrieving parameters for an applet: Defining and Using Applet Parameters (The Java™ Tutorials > Deployment > Applets)

  7. #7
    Junior Member
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Push Notification Client/Server

    Ahh yes its a wonderful day.. I was so tired yesterday after my 14 hour non-stop shift working on the above classes I failed to see just how simple a client that employs this service really is. So how do I intend to make this service useful across many machines, server-side technologies and architectures? The answer is simple: JAVA!

    Most server-side technologies have access to the command line interface. Thusly I have written a very arcane class to provide CLI access to the TWO-PROCEDURE class that is the client.

    NOTICE: Before you use this class, you should note that line 183 in web.site.push.Listener (in post #5) was recently updated (commented out) to work with this client. This client expects only two bytes of status information. The previous code provided 3.

    Ladies and Gentleman, I give you web.site.Push:
    package web.site;
     
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.nio.ByteBuffer;
     
    public class Push {
     
    	public static int Notice(String host, int port, int operation, int flags) {
     
    		int errCode = 0;
     
    		byte[] in = new byte[2];
    		byte[] out = new byte[8];
     
    		ByteBuffer writer = ByteBuffer.wrap(out);
     
    		writer.putInt(operation);
    		writer.putInt(flags);
     
    		try {
     
    		  Socket remote = new Socket(host, port);
     
    		  InputStream is = remote.getInputStream();
     
    		  is.read(in, 0, 2);
     
    		  if (in[0] == 6 && in[1] == 22) { // Server is waiting for input!
     
    			OutputStream os = remote.getOutputStream();
    			os.write(out);
    			os.flush();
    			is.read(in, 0, 2);
     
    			if (in[0] == 21) { // we timed out!
    				System.err.println("Remote notification failed to synchronize: " + host + encase(port));
    				errCode = 4;
    			}
     
    		  } else { errCode = 3; } // our input was rejected :(
     
    		  remote.close();
     
    		}
     
    		catch (UnknownHostException ex) { // we couldn't connect!
     
    		  System.err.println(ex);
    		  return 1;
     
    		}
     
    		catch (IOException ex) { // something seriously screwed up..
     
    		  System.err.println(ex);
    		  return 2;
     
    		}
     
    		return errCode;
     
    	}
     
    	private static String encase(int num) {
    		return " (" + num + ")";
    	}
     
    }

    Pretty straight-forward and self documenting I might add. And finally a CLI to allow shell access to CGI programs and scripts web.site.cli.Notify:

    package web.site.cli;
     
    public class Notify {
     
    	public static void main(String[] args) {
     
    		if (args.length != 4) {
    			System.err.println("Error: expected 4 arguments {Basic notation: $host %port %command %flags} (Java notation: String int int int)");
    			System.exit(5);
    		}
     
    		System.exit(web.site.Push.Notice(args[0], Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3])));
     
    	}
     
    }

    Unfortunately, I still have not had the oppertunity to test any of these classes. But this is a solid concept presented here. I also wanted to add some examples however I believe from a beginners point of view all of this software is self explanatory provided you are educated in the underlying technologies. The CLI itself explains pretty fairly how to use the client. Some HTML to define a listener would look something like this:

    HTML Code:
    <applet id="listener" code="web.site.push.Target" archive="web-tools-signed.jar"
     style="width: 0px; height: 0px; float: left;" mayscript>
    <param name="Name" value="listener">
    <param name="LocalPort" value="2011">
    <param name="onPush" value="listeners_Push">
    <param name="onDebug" value="listeners_Debug">
    <param name="onActivate" value="listeners_Activate">
    <param name="onTerminate" value="listeners_Terminate">
    <param name="onConnectionRefused" value="listeners_ConnectionRejected">
    <param name="RemoteClients" value="myhost.somesite.com myhost2.it 249.148.127.100">
    </applet>
    Access to the public methods of the applet are considered trivial here. If more information is required consult any tutorial on: LiveScript (java/javascript intermingling for web browsers)

    For all practical purposes and intents, I will supply the JS method signatures for your convenience.

    HTML Code:
    <script>
    function listeners_ConnectionRejected(ServiceName, RemoteHostName, RemoteIP) {}
    function listeners_Terminate(ServiceName) {}
    function listeners_Activate(ServiceName) {}
    function listeners_Debug(ServiceName, MessageText) {}
    function listeners_Push(ServiceName, RemoteHostName, DesiredOperation, Flags) {}
    </script>
    If this concept is not an example you can follow with logic you might be in the wrong forum! However I will answer any meaningful questions directed at me about this software/concept. I am no java Guru so don't expect me to discuss JVM execution philosophy or something else that really has nothing to do with this software/concept.

    If you will run from the server side using something like
    perl/php/bash/basic/js/BATCH/vbscript/Visual Basic/Wscript/Assembler/C/C#/C++/.NET
    you will need to learn about running shell commands and capturing STDERR by using redirects to a file or simply using some method to capture the stream to a variable. You will also need to study how to build a java command line application to allow the CLI Notification class to be executed by the java command.

    {String Host} {int Port} {int Operation} {int Flags}
    These are the four fields the Command Line Interface program expects to find as arguments. If more or less are found an error is "thrown" and the application will exit with a status code of 5. If the operation is successful status code will be zero. Codes 1-4 are defined (in code as return values) within the web.site.Push class.

    If you have any questions about the JavaScript Method Signatures please consult the web.site.push.Target method that calls each of them respectively. If you are using JSP you only need to call the Static method Notice located in web.site.Push refer to the CLI class for more information.

    web.site.Push.Notice(String host, int port, int operation, int flags);

    Have a great day, and please be sure to inform myself and others of your progress or findings!
    Last edited by MistaWizurd; April 29th, 2011 at 02:33 PM. Reason: Added information to reflect edits in post #5. Corrected ConnectionRejected Method signature.

  8. #8
    Junior Member
    Join Date
    Apr 2011
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Lightbulb Re: Push Notification Client/Server



    I believe this is what I call a wrap for this thread. Everything hasn't been tested "to the extreme" but many improvements have been made over the code. It can call scripts and handle any exceptions they may raise that previously would have crashed the applet. It works well enough to send/receive push notifications in a timely manner, and handles errors gracefully. That was my intent. I hope this project satisfies your intents as well.

    The maximum amount of remote connections to the server has been reduced to 16. The buffers are set to handle what the code expects, and the client will standby for no longer than one second before "giving up" on notifying the server. The server itself will not wait any longer than 8 10ths of a second while communicating with a client.

    You will find attached to this post a zip file containing: A windows batch file for executing a server test. A Unix shell script for executing a server test. An HTML file for testing in your browser either locally or hosted from a server, a compiled and signed Java Archive for demonstration and the full WORKING source code (some assembly required.)

    Suggested Improvements:
    • Multiple network interface handling for the client
    • Multiple network interface handling for the server
    • Anything you can innovate through hard work and determination


    The author of this project assumes no liability and grants you the rights to do anything with this code other than apply for a patent or copyright based on this software or concept.
    webtools.test.zip

Similar Threads

  1. simple ftp server and ftp client
    By simontkk2005 in forum Java Networking
    Replies: 4
    Last Post: January 26th, 2011, 10:29 AM
  2. [Java] Client - server, example
    By Grabar in forum Java Networking
    Replies: 6
    Last Post: January 22nd, 2011, 01:56 PM
  3. client server communication
    By Brt93yoda in forum Java Theory & Questions
    Replies: 4
    Last Post: September 2nd, 2010, 04:49 PM
  4. Client/Server
    By Dillz in forum Paid Java Projects
    Replies: 2
    Last Post: June 2nd, 2010, 05:19 AM
  5. Client-Server program
    By Reztem in forum What's Wrong With My Code?
    Replies: 0
    Last Post: May 12th, 2010, 05:36 PM