-
June 18th, 2004, 06:55 AM
#1
Java Alert for Remedy
Hello!
I need a Java Programm to get Alert notifications from the Remedy ARS 5.1.2 i have alredy begin to programm something but there are Problems. Here my code
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import com.remedy.arsys.api.*;
public class Alert
{
ServerSocket ssock = null;
Socket sock =null;
ARServerUser context = null;
public Alert()
{
super();
try
{
context = new ARServerUser();
Util.ARSetServerPort( context,new NameID(""), 0, 0 );
context.login();
System.out.println( "Login successful");
try
{
ssock = new ServerSocket(4000);
System.out.println(" "+ssock.getInetAddress());
}
catch (IOException e)
{e.printStackTrace();}
Util.ARRegisterForAlerts(context,4000,0);
System.out.println( "Registered");
System.out.println("Anzahl der Alerts : "+Util.ARGetAlertCount(context,null));
try
{
d=0;
do
{
try
{
System.out.println("Starting Accept");
sock = ssock.accept();
System.out.println("Accept");
}
catch (IOException e1)
{e1.printStackTrace();}
try
{
sock.setSoLinger(true,1);
sock.setReuseAddress(true);
}
catch (SocketException se)
{se.printStackTrace();}
int reader;
String message ="";
byte[] data = "ack".getBytes();
DataInputStream din = new DataInputStream(sock.getInputStream());
DataOutputStream dou = new DataOutputStream(sock.getOutputStream());
System.out.println("Available"+din.available());
while((reader = din.read()) != -1)
{
System.out.println(""+reader);
message += (char) (0xFF & (byte) reader);
} System.out.println("\n message \n"+message);
dou.write(data , 0, data .length);
dou.flush();
AlertMessageCriteria alertcrit = new AlertMessageCriteria(); alertcrit.setRetrieveAll(true);
try
{
AlertMessageInfo msg = Util.ARDecodeAlertMessage(context,alertcrit,message,message.length());
System.out.println(msg.getServerName());
}
catch (Exception e)
{System.out.println("DEcoding Error\n");}
din.close();
dou.close();
sock.close();
}while(++d<3);
}
catch (IOException e4)
{e4.printStackTrace();}
Util.ARDeregisterForAlerts(context,4000);
System.out.println("nicht mehr regestriert");
}
catch (ARException e3)
{e3.printStackTrace();}
catch (Exception e4)
{e4.printStackTrace();}
context.logout();
System.out.println("Logout");
}
Hope somebody can help me??
How must i read from the socket??
The param in the DecodeAlertMessage Funktion needs a String!"
Last edited by Frozen19; June 22nd, 2004 at 01:46 AM.
-
June 18th, 2004, 10:24 AM
#2
Re: Java Alert for Remedy
Originally posted by Frozen19
... there are Problems
hmm.. that's helpful..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|