source: trunk/src/org/expeditee/network/Peer.java@ 309

Last change on this file since 309 was 298, checked in by ra33, 16 years ago

Adding networking stuff for peer to peer sharing of frames

File size: 931 bytes
Line 
1package org.expeditee.network;
2
3import java.net.InetAddress;
4import java.net.SocketAddress;
5import java.net.UnknownHostException;
6
7import org.expeditee.gui.AttributeValuePair;
8import org.expeditee.gui.MessageBay;
9
10public class Peer {
11 public static final int DEFAULT_PORT = 3000;
12
13 private String name_ = null;
14
15 private int port_ = DEFAULT_PORT;
16
17 private InetAddress ip_ = null;
18
19 public Peer(AttributeValuePair avp) throws UnknownHostException {
20 name_ = avp.getAttribute();
21 String[] address = avp.getValue().split("\\s+");
22
23 ip_ = InetAddress.getByName(address[0]);
24
25 if (address.length > 1) {
26 try {
27 port_ = Integer.parseInt(address[1]);
28 } catch (Exception e) {
29 MessageBay.errorMessage("Could not parse port in ["
30 + avp.toString() + "]");
31 }
32 }
33 }
34
35 public int getPort() {
36 return port_;
37 }
38
39 public InetAddress getAddress() {
40 return ip_;
41 }
42
43 public String getName() {
44 return name_;
45 }
46}
Note: See TracBrowser for help on using the repository browser.