| Protocol.java |
1 // Copyright (c) 2004 Just Objects B.V. <just@justobjects.nl>
2 // Distributable under LGPL license. See terms of license at gnu.org.
3
4 package nl.justobjects.pushlet.core;
5
6
7 /**
8 * Constants for Pushlet protocols.
9 *
10 * @author Just van den Broecke - Just Objects ©
11 * @version $Id: Protocol.java,v 1.15 2007/11/23 14:33:07 justb Exp $
12 */
13public interface Protocol {
14 /**
15 * Default URI .
16 */
17 public static final String DEFAULT_SERVLET_URI = "/pushlet/pushlet.srv";
18
19 //
20 // Common protocol header/parameter names
21 //
22
23 /**
24 * Event type (join, leave, data, subscribe etc) .
25 */
26 public static final String P_EVENT = "p_event";
27
28 /**
29 * Time in seconds since 1970
30 */
31 public static final String P_TIME = "p_time";
32
33 /**
34 * Event sequence number, numbers per-client.
35 */
36 public static final String P_SEQ = "p_seq";
37
38 /**
39 * Subject (topic) of data event.
40 */
41 public static final String P_SUBJECT = "p_subject";
42
43 /**
44 * Originator of Event.
45 */
46 public static final String P_FROM = "p_from";
47
48 /**
49 * Addressee of Event, subject or client p_id.
50 */
51 public static final String P_TO = "p_to";
52
53 /**
54 * Identifier for client instance within server.
55 */
56 public static final String P_ID = "p_id";
57
58 /**
59 * Subscription id, identifies single subscription.
60 */
61 public static final String P_SUBSCRIPTION_ID = "p_sid";
62
63 /**
64 * Format to receive events
65 */
66 public static final String P_FORMAT = "p_format";
67
68 /**
69 * Protocol mode.
70 */
71 public static final String P_MODE = "p_mode";
72
73 /**
74 * Reason for errors.
75 */
76 public static final String P_REASON = "p_reason";
77
78 /**
79 * URL attribute.
80 */
81 public static final String P_URL = "p_url";
82
83 /**
84 * Wait attribute.
85 */
86 public static final String P_WAIT = "p_wait";
87
88 /**
89 * Subscription label, may be used to return user-specific
90 * token with a data event, e.g. the name of a function for a callback.
91 */
92 public static final String P_SUBSCRIPTION_LABEL = "p_label";
93
94 //
95 // Event values with direction for P_EVENT (C=client, S=server)
96 //
97
98 /**
99 * C-->S Request to join server.
00 */
01 public static final String E_JOIN = "join";
02
03 /**
04 * S-->C Acknowledgement of join.
05 */
06 public static final String E_JOIN_ACK = "join-ack";
07
08 /**
09 * C-->S Request to join server.
10 */
11 public static final String E_JOIN_LISTEN = "join-listen";
12
13 /**
14 * S-->C Acknowledgement of join.
15 */
16 public static final String E_JOIN_LISTEN_ACK = "join-listen-ack";
17
18 /**
19 * C-->S Client starts listening.
20 */
21 public static final String E_LISTEN = "listen";
22
23 /**
24 * S-->C Ack of listen.
25 */
26 public static final String E_LISTEN_ACK = "listen-ack";
27
28 /**
29 * C-->S Client leaves server.
30 */
31 public static final String E_LEAVE = "leave";
32
33 /**
34 * S-->C Ack of leave.
35 */
36 public static final String E_LEAVE_ACK = "leave-ack";
37
38 /**
39 * C-->S Publish to subject.
40 */
41 public static final String E_PUBLISH = "publish";
42
43 /**
44 * S-->C Publish to subject acknowledge.
45 */
46 public static final String E_PUBLISH_ACK = "publish-ack";
47
48 /**
49 * C-->S Subscribe to subject request.
50 */
51 public static final String E_SUBSCRIBE = "subscribe";
52
53 /**
54 * S-->C Subscribe to subject acknowledge.
55 */
56 public static final String E_SUBSCRIBE_ACK = "subscribe-ack";
57
58 /**
59 * C-->S Unsubscribe from subject request.
60 */
61 public static final String E_UNSUBSCRIBE = "unsubscribe";
62
63 /**
64 * S--C Unsubscribe from subject acknowledge.
65 */
66 public static final String E_UNSUBSCRIBE_ACK = "unsubscribe-ack";
67
68 /**
69 * S-->C Client error response, transitional error.
70 */
71 public static final String E_NACK = "nack";
72
73 /**
74 * S-->C Client should abort, permanent error.
75 */
76 public static final String E_ABORT = "abort";
77
78 /**
79 * S-->C Data.
80 */
81 public static final String E_DATA = "data";
82
83 /**
84 * S-->C or C-->S Heartbeat.
85 */
86 public static final String E_HEARTBEAT = "hb";
87
88 /**
89 * S-->C S-->C or C-->S Heartbeat confirmed.
90 */
91 public static final String E_HEARTBEAT_ACK = "hb-ack";
92
93 /**
94 * S-->C or C-->S client refresh of data channel.
95 */
96 public static final String E_REFRESH = "refresh";
97
98 /**
99 * S-->C client should refresh data channel.
00 */
01 public static final String E_REFRESH_ACK = "refresh-ack";
02
03 //
04 // Values for P_FORMAT parameter
05 //
06
07 /**
08 * JavaScript callback.
09 */
10 public static String FORMAT_JAVASCRIPT = "js";
11
12 /**
13 * Java serialized object.
14 */
15 public static String FORMAT_SERIALIZED_JAVA_OBJECT = "ser";
16
17 /**
18 * Stream of XML documents.
19 */
20 public static String FORMAT_XML = "xml";
21
22 /**
23 * Single XML document containing zero or more events.
24 */
25 public static String FORMAT_XML_STRICT = "xml-strict";
26
27 //
28 // Values for P_MODE parameter
29 //
30 public static final String MODE_STREAM = "stream";
31 public static final String MODE_PULL = "pull";
32 public static final String MODE_POLL = "poll";
33
34 //
35 // Values for special/reserved subjects
36 // TODO: use these to publish events when clients do these actions
37 // TODO: Dispatcher may intercept these subjects to send cached events
38 //
39 public static final String SUBJECT_META = "/meta";
40 public static final String SUBJECT_META_SUBS = SUBJECT_META + "/subs";
41 public static final String SUBJECT_META_JOINS = SUBJECT_META + "/joins";
42
43
44}
45
46/*
47 * $Log: Protocol.java,v $
48 * Revision 1.15 2007/11/23 14:33:07 justb
49 * core classes now configurable through factory
50 *
51 * Revision 1.14 2006/10/19 12:33:40 justb
52 * add atomic join-listen support (one request)
53 *
54 * Revision 1.13 2005/05/06 19:44:00 justb
55 * added xml-strict format
56 *
57 * Revision 1.12 2005/02/28 13:05:59 justb
58 * introduced join-listen protocol service
59 *
60 * Revision 1.11 2005/02/28 12:45:59 justb
61 * introduced Command class
62 *
63 * Revision 1.10 2005/02/16 12:16:17 justb
64 * added support for "poll" mode
65 *
66 * Revision 1.9 2005/01/24 22:46:02 justb
67 * getting safari to work
68 *
69 * Revision 1.8 2005/01/24 13:42:00 justb
70 * new protocol changes (p_listen)
71 *
72 * Revision 1.7 2005/01/18 16:47:10 justb
73 * protocol changes for v2 and publishing from pushlet client
74 *
75 * Revision 1.6 2005/01/13 14:47:15 justb
76 * control evt: send response on same (control) connection
77 *
78 * Revision 1.5 2004/10/24 13:52:52 justb
79 * small fixes in client lib
80 *
81 * Revision 1.4 2004/10/24 12:58:18 justb
82 * revised client and test classes for new protocol
83 *
84 * Revision 1.3 2004/09/20 22:01:38 justb
85 * more changes for new protocol
86 *
87 * Revision 1.2 2004/09/03 22:35:37 justb
88 * Almost complete rewrite, just checking in now
89 *
90 * Revision 1.1 2004/09/03 21:02:20 justb
91 * make more formalized protocol
92 *
93 *
94 */
95| Protocol.java |