Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  chat prog  (Read 1355 times)
0 Members and 1 Guest are viewing this topic.
Offline chris_gillis

Junior Newbie




Java games rock!


« Posted 2003-10-30 22:35:31 »

I'm interested(besides other matters) in making a small little chat application, where if person A starts it up, and person B starts it up, they can both perform chatting operations


this can be very simple with no gui at all, where should i start...
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2003-10-31 04:20:54 »

java.net.*

I'm not sure what else to tell you with as general a question as this.

(If you don't even know what a TCP socket is, then get a decent beginning book on networking.)

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline DoronBarak

Senior Newbie




Jave Games Rock, especially paper-rock-scissors!


« Reply #2 - Posted 2004-05-09 00:15:51 »

Quote
I'm interested(besides other matters) in making a small little chat application, where if person A starts it up, and person B starts it up, they can both perform chatting operations


this can be very simple with no gui at all, where should i start...


Chat programs need a server which they use as a means of a lobby, or a common meeting place where people can locate one-another so they can start chatting.

You can use proper IRC servers for this if you like, or setup your own server which will have to be anchored to the Internet -- i.e. have a permanent domain name.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.net.*;
import java.io.*;
import java.security.*;

final class MySecurityManager extends SecurityManager {
      public void checkPermission(Permission perm) {}

      public void checkPermission(Permission perm, Object context) {}
}

public class IrcApplet extends Applet implements Runnable {
      // IRC Stuff..
      private Socket s;
      private BufferedWriter bw;
      private BufferedReader br;
      private Thread t;
      // GUI Stuff..
      private boolean isStandalone = false;
      private BorderLayout borderLayout1 = new BorderLayout();
      private Panel panel1 = new Panel();
      private TextField tfIrcText = new TextField();
      private BorderLayout borderLayout2 = new BorderLayout();
      private Panel panel2 = new Panel();
      private Panel panel3 = new Panel();
      private Panel panel4 = new Panel();
      private Panel panel5 = new Panel();
      private Panel panel6 = new Panel();
      private BorderLayout borderLayout3 = new BorderLayout();
      private Panel panel7 = new Panel();
      private Panel panel8 = new Panel();
      private Panel panel9 = new Panel();
      private TextArea textArea1 = new TextArea();
      private Panel panel10 = new Panel();
      private BorderLayout borderLayout4 = new BorderLayout();
      private Panel panel11 = new Panel();
      private Button btnConnect = new Button();
      private BorderLayout borderLayout5 = new BorderLayout();
      private Panel panel12 = new Panel();
      private Panel panel13 = new Panel();
      //Get a parameter value
      public String getParameter(String key, String def) {
            return isStandalone ? System.getProperty(key, def) :
                  (getParameter(key) != null ? getParameter(key) : def);
      }

      //Construct the applet
      public IrcApplet() {
      }

      //Initialize the applet
      public void init() {
            try {
                  jbInit();
            } catch (Exception e) {
                  e.printStackTrace();
            }
      }

      //Component initialization
      private void jbInit() throws Exception {
            this.setLayout(borderLayout1);
            panel1.setLayout(borderLayout2);
            tfIrcText.setText("");
            tfIrcText.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                        tfIrcTextActionPerformed(e);
                  }
            });
            panel6.setLayout(borderLayout3);
            textArea1.setColumns(80);
            textArea1.setEditable(false);
            textArea1.setRows(20);
            textArea1.setText("");
            panel10.setLayout(borderLayout4);
            btnConnect.setLabel("Connect");
            btnConnect.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                        btnConnectActionPerformed(e);
                  }
            });
            panel5.setLayout(borderLayout5);
            this.add(panel1, BorderLayout.NORTH);
            panel1.add(tfIrcText, BorderLayout.CENTER);
            panel1.add(panel2, BorderLayout.SOUTH);
            panel1.add(panel3, BorderLayout.WEST);
            panel1.add(panel4, BorderLayout.EAST);
            panel1.add(panel5, BorderLayout.NORTH);
            panel5.add(panel10, BorderLayout.CENTER);
            panel10.add(panel11, BorderLayout.WEST);
            panel11.add(btnConnect, null);
            panel5.add(panel12, BorderLayout.EAST);
            panel5.add(panel13, BorderLayout.WEST);
            this.add(panel6, BorderLayout.CENTER);
            panel6.add(textArea1, BorderLayout.CENTER);
            panel6.add(panel7, BorderLayout.SOUTH);
            panel6.add(panel8, BorderLayout.EAST);
            panel6.add(panel9, BorderLayout.WEST);
      }

      //Get Applet information
      public String getAppletInfo() {
            return "Applet Information";
      }

      //Get parameter info
      public String[][] getParameterInfo() {
            return null;
      }

      void btnConnectActionPerformed(ActionEvent e) {
            try {
                  s = new Socket("irc.shadowworld.net", 6667);
                  InputStream is = s.getInputStream();
                  OutputStream os = s.getOutputStream();
                  InputStreamReader isr = new InputStreamReader(is);
                  OutputStreamWriter osw = new OutputStreamWriter(os);
                  bw = new BufferedWriter(osw);
                  br = new BufferedReader(isr);
                  t = new Thread(this);
                  t.start();
                  processInput("NICK WizKid");
                  processInput(":WizKid USER WizKid TEST TEST :FirstName LastName");
            } catch (Exception ex) {
                  ex.printStackTrace();
            }
      }

      public void processInput(String text) {
            try {
                  bw.write(text);
                  bw.newLine();
                  bw.flush();
            } catch (IOException ex) {
                  ex.printStackTrace();
            }
      }

      private void respondToOutput(String value) {
            if (value.startsWith("PING")) {
                  value = value.replaceFirst("PING", "PONG");
                  processInput(value);
            }
      }

      public void addToOutput(String outputString) {
            textArea1.append(outputString);
            textArea1.append("\r\n");
      }

      public void run() {
            String line = null;
            while (Thread.currentThread() == t) {
                  try {
                        line = br.readLine();
                        if (line != null) {
                              addToOutput(line);
                              respondToOutput(line);
                        } else {
                              t = null;
                        }
                  } catch (IOException ex) {
                        ex.printStackTrace();
                  }
            }
      }

      void tfIrcTextActionPerformed(ActionEvent e) {
            processInput(tfIrcText.getText());
            tfIrcText.setText(null);
      }
}


I wrote the above applet, it connects to an IRC server and lets you chat (although very primitively of course)

If you're going the IRC way, you'd need to implement some of the IRC guideline as specified in RFC1459 at http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc1459.html for instance.

If you're going for a chat applet, you could also use the information here http://forum.java.sun.com/thread.jsp?forum=54&thread=383859 to sign the applet and host it on whatever site you want to.

Hope this helps Smiley

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

SHC (24 views)
2014-11-25 12:00:59

SHC (22 views)
2014-11-25 11:53:45

Norakomi (19 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (41 views)
2014-11-12 21:09:33

kovacsa (67 views)
2014-11-07 19:57:14
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!