package uk.ac.ntu.n0521366.wsyd.libs.message;
import java.io.Serializable;
-import java.net.InetAddress;
/**
* Base class of all Message types.
* @author Eddie Berrisford-Lynch <dev@fun2be.me>
*/
public class MessageLogRecord extends MessageAbstract {
+ /**
+ * Message type.
+ */
private static final String _type = "LogRecord";
/**
/*
* The MIT License
*
- * Copyright 2015 TJ <hacker@iam.tj>.
+ * Copyright 2015 Eddie Berrisford-Lynch <dev@fun2be.me>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
/**
* A specialised message containing a WSYD_Member.
*
- * @author TJ <hacker@iam.tj>
+ * @author Eddie Berrisford-Lynch <dev@fun2be.me>
*/
public class MessageMember extends MessageAbstract {
+ /**
+ * Registration states.
+ */
public static enum STATE {UNREGISTERED, REGISTERED};
+
+ /**
+ * Message type.
+ */
private static final String _type = "WSYD_Member";
+ /**
+ * Member record.
+ */
private WSYD_Member _member;
+
+ /**
+ * Registration state.
+ */
private STATE _registered;
+
+ /**
+ * Optional registration status message (used by server as error hint)
+ */
private String _status;
+ /**
+ * The Message Class type.
+ *
+ * @return Message type
+ */
public static String getType() {
return _type;
}
+ /**
+ * The purpose of this class of message.
+ *
+ * @return "WSYD_Member"
+ */
@Override
public String getMessageType() {
return _type;
}
+ /**
+ * Create with a member record and current status.
+ * @param member the member
+ * @param registered true if registered
+ * @param status optional status hint (set by server when errors occur)
+ */
public MessageMember(WSYD_Member member, STATE registered, String status) {
+ super();
_member = member;
_registered = registered;
_status = status;
}
+ /**
+ * Create with a member record.
+ *
+ * @param member the member
+ */
public MessageMember(WSYD_Member member) {
this(member, STATE.UNREGISTERED, null);
}
+ /**
+ * Default constructor.
+ */
public MessageMember() {
this(null, STATE.UNREGISTERED, null);
}
/**
* Get the Member contained in this message.
*
- * @return
+ * @return the member record
*/
public WSYD_Member getMember() {
return _member;
/**
* Current registration state of the member record contained in this message.
*
- * @return
+ * @return the registration status
*/
public STATE getRegistered() {
return _registered;
/**
* Get registration status message.
*
- * @return
+ * @return an optional message describing the registration status (usually an error hint)
*/
public String getStatus() {
return _status;
/*
* The MIT License
*
- * Copyright 2015 eddie.
+ * Copyright 2015 Eddie Berrisford-Lynch <dev@fun2be.me>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
/**
* Pass a NetworkStream reference in a message.
*
- * @author eddie
+ * @author Eddie Berrisford-Lynch <dev@fun2be.me>
*/
public class MessageNetworkStream extends MessageAbstract {
+ /**
+ * Message type.
+ */
public static final String _type = "NetworkStream";
+ /**
+ * the stream reference.
+ */
public final NetworkStream _stream;
+ /**
+ * The Message Class type.
+ *
+ * @return Message type
+ */
public static String getType() {
return _type;
}
+ /**
+ * The purpose of this class of message.
+ *
+ * @return "NetworkStream"
+ */
@Override
public String getMessageType() {
return _type;
}
+ /**
+ * Create with a stream reference.
+ * @param stream the stream
+ */
public MessageNetworkStream(NetworkStream stream) {
super();
_stream = stream;
import uk.ac.ntu.n0521366.wsyd.libs.net.WSYD_SocketAddress;
/**
- *
+ * Announcement over multicast neighbour discovery.
+ *
* @author Eddie Berrisford-Lynch <dev@fun2be.me>
*/
public class MessagePresence extends MessageAbstract {
- private static final String _type = "Presence";
-
/**
- * Return the class type without needing an instance object.
- *
- * Workaround for Java not permitting 'abstract static' qualifiers which would
- * allow static methods in abstract base classes to be overridden in sub-classes.
- *
- * @return class type
+ * Message type.
*/
- public static String getType() {
- return _type;
- }
+ private static final String _type = "Presence";
/**
* The title of the service advertising itself.
*
- * E.g. "ServerSocial", "ServerChat", "ServerLog","UserSocial", 'UserChat", "Notify"
+ * E.g. "ServerSocial", "ServerChat", "ServerLog", "UserChat"
*/
public String serviceName;
*/
public WSYD_SocketAddress socketAddress;
+ /**
+ * The Message Class type.
+ *
+ * @return Message type
+ */
+ public static String getType() {
+ return _type;
+ }
+
/**
- * The message type
+ * The purpose of this class of message.
+ *
* @return "Presence"
*/
@Override
return _type;
}
+ /**
+ * Construct a message that can be sent over the network.
+ * @param service Name of the service being announced
+ * @param socketAddress IP address and port of the service
+ */
public MessagePresence(String service, WSYD_SocketAddress socketAddress) {
super();
this.serviceName = service;