コード例 #1
0
 protected void receive(String content, String address, Session session) {
   try {
     IncomingMessage<?> message = _factory.create(content);
     message.setAddress(address);
     message.setSession(session);
     message.execute();
   } catch (UserException e) {
     send(User.parseAddress(address), new NotLogon());
   } catch (Exception e) {
     Logger.getInstance().error(e);
   }
 }
コード例 #2
0
 public void send(String address, OutgoingMessage message) {
   try {
     message.populateJSON();
     URLConnection connection = new URL(address).openConnection();
     connection.setConnectTimeout(30000);
     connection.setReadTimeout(30000);
     setSession(connection);
     connection.setDoOutput(true);
     OutputStream out = connection.getOutputStream();
     out.write(message.toString().getBytes());
     out.close();
     connection.getInputStream().close();
     rememberSession(connection);
   } catch (Exception e) {
     Logger.getInstance().error(e);
   }
 }