CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Location
    Vienna
    Posts
    1

    Question 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.

  2. #2
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: Java Alert for Remedy

    Originally posted by Frozen19
    ... there are Problems
    hmm.. that's helpful..
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured