/**
* Creates a new client session. Initializes the
- * @param service The remove service.
+ * @param service The remote service.
*/
public ClientSession(String service) throws ConfigException {
+ this(service, null);
+ }
+
+ /**
+ * Creates a new client session. Initializes the
+ * @param service The remote service.
+ * @param locale The locale for this session.
+ */
+ public ClientSession(String service, String locale) throws ConfigException {
this.service = service;
+ if(locale != null)
+ setLocale(locale);
/** generate the remote node string */
domain = (String) Config.global().getFirst("/domain");
private String type;
/** message payload */
private Object payload;
+ /** message locale */
+ private String locale;
/** Create a registry for the osrfMessage object */
private static OSRFRegistry registry =
OSRFRegistry.registerObject(
"osrfMessage",
OSRFRegistry.WireProtocol.HASH,
- new String[] {"threadTrace", "type", "payload"});
+ new String[] {"threadTrace", "type", "payload", "locale"});
/**
* @param id This message's ID
setPayload(payload);
}
+ /**
+ * @param id This message's ID
+ * @param type The type of message
+ * @param payload The message payload
+ * @param locale The message locale
+ */
+ public Message(int id, String type, Object payload, String locale) {
+ this(id, type, payload);
+ setPayload(payload);
+ setLocale(locale);
+ }
+
public int getId() {
return id;
public Object getPayload() {
return payload;
}
+ public String getLocale() {
+ return locale;
+ }
public void setId(int id) {
this.id = id;
}
public void setPayload(Object p) {
payload = p;
}
+ public void setLocale(String l) {
+ locale = l;
+ }
/**
* Implements the generic get() API required by OSRFSerializable
return getType().toString();
if("payload".equals(field))
return getPayload();
+ if("locale".equals(field))
+ return getLocale();
return null;
}
* Sends the request to the server.
*/
public void send() throws SessionException {
- session.send(new Message(id, Message.REQUEST, method));
+ session.send(new Message(id, Message.REQUEST, method, session.getLocale()));
}
/**
/** The address of the remote party we are communicating with */
private String remoteNode;
+ /** Session locale */
+ protected String locale;
+ /** Default session locale */
+ protected static String defaultLocale = "en_US";
+
/**
* The thread is used to link messages to a given session.
* In other words, each session has a unique thread, and all messages
public void setThread(String thread) {
this.thread = thread;
}
+
+ /**
+ * Get locale.
+ * @return locale as String.
+ */
+ public String getLocale() {
+ if(locale == null)
+ return defaultLocale;
+ return locale;
+ }
+
+ /**
+ * Set locale.
+ * @param locale the value to set.
+ */
+ public void setLocale(String locale) {
+ this.locale = locale;
+ }
+
+ /**
+ * Get defaultLocale.
+ * @return defaultLocale as String.
+ */
+ public String getDefaultLocale() {
+ return defaultLocale;
+ }
+
+ /**
+ * Set defaultLocale.
+ * @param defaultLocale the value to set.
+ */
+ public void setDefaultLocale(String defaultLocale) {
+ this.defaultLocale = defaultLocale;
+ }
+
/**
* Get connectState.