{"id":283272,"date":"2016-12-29T20:40:04","date_gmt":"2016-12-29T17:40:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=283272"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=283272","title":{"rendered":"Java socket framework"},"content":{"rendered":"<p>\u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a.<br \/>  \u0420\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e \u043e\u043d\u043b\u0430\u0439\u043d 3\u0434 \u0438\u0433\u0440\u0443, \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 java. \u0414\u043b\u044f 3d \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0434\u0432\u0438\u0436\u043e\u043a jmonkeyengine. <br \/>  \u0410 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438 p2p \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, MVC \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435.<br \/>  <a name=\"habracut\"><\/a><br \/>  <b>\u0413\u0434\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f:<br \/>  <\/b><br \/>  1. \u0421\u0435\u0440\u0432\u0435\u0440 \u0434\u043b\u044f \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432.<br \/>  2. \u041b\u044e\u0431\u044b\u0435 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e p2p.<br \/>  3. \u041e\u043d\u043b\u0430\u0439\u043d \u0438\u0433\u0440\u044b.<br \/>  4. \u0422\u043e\u0440\u0440\u0435\u043d\u0442 \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438.<\/p>\n<p>  <b>\u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430:<br \/>  <\/b><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/947\/d0c\/071\/947d0c07163110b07a210a8ce130a573.jpg\" alt=\"image\"\/><br \/>  <b>\u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b:<\/b><br \/>  1. \u041a\u043b\u0438\u0435\u043d\u0442 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u043e\u043e\u0431\u0435\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u043a\u0430\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0432\u044b\u0437\u0432\u0430\u0442\u044c.<br \/>  2. \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<br \/>  3. \u0420\u043e\u0443\u0442\u0435\u0440 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u044d\u0442\u0438\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438.<br \/>  4. \u0412 \u0437\u0430\u0434\u0430\u0447\u0435 \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<p>  <b>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438:<\/b><br \/>  1. \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0440\u0442\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<br \/>  2. \u041c\u043e\u0434\u0435\u043b\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<br \/>  3. \u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<br \/>  4. \u041f\u0440\u0430\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<br \/>  5. \u041c\u043e\u0434\u0443\u043b\u0438.<br \/>  6. \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u0435\u0441\u0441\u0438\u0439.<br \/>  7. \u041a\u043e\u043c\u0430\u043d\u0434\u044b.<br \/>  8. \u0421\u043c\u0435\u043d\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 tcp\/udp.<\/p>\n<p>  <b>\u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438, \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\u044f.<br \/>  <\/b><br \/>  <a href=\"http:\/\/jsockframework.blogspot.ru\/\">http:\/\/jsockframework.blogspot.ru\/<br \/>  <\/a><br \/>  <a href=\"https:\/\/github.com\/nnpa\/jsock\/\">https:\/\/github.com\/nnpa\/jsock\/<\/a><br \/>  <a href=\"https:\/\/www.youtube.com\/playlist?list=PLURYMl31iZR4Oi234nodt4cV6GMYV8NJ5\">youtube<\/a><\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0438 \u043f\u0440\u0438\u0435\u043c\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<br \/>  <\/b><br \/>  <b>\u041a\u043b\u0438\u0435\u043d\u0442<\/b>  <\/p>\n<pre><code class=\"java\">\/\/client \/*  * jsock framework https:\/\/github.com\/nnpa\/jsock open source  * Each line should be prefixed with  *   *\/  package jsock.tests;  import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.util.Iterator; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger; import conf.JConfig; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException;  \/**  *  * @author padaboo I.B Aleksandrov jetananas@yandex.ru  *\/ public class JClientTCPTest {          public static void main(String[] args) throws UnknownHostException, IOException, ClassNotFoundException, InterruptedException{        JClientTCPTest tcpTest = new JClientTCPTest();        tcpTest.test();                      }          public void test(){         Sender sender     = new Sender();         sender.start();                  Receiver receiver = new Receiver();         receiver.start();     }          class Sender extends Thread{         @Override         public void run(){             try {                 InetAddress host = InetAddress.getLocalHost();                 Socket socket    = null;                                  String message;                                  for(int i=1; i&lt;10;i++){                     message = &quot;{\\&quot;task\\&quot;:\\&quot;JTestTask\\&quot;,\\&quot;message\\&quot;:\\&quot;test&quot;+i+&quot;\\&quot;}&quot;;                     socket = new Socket(host.getHostName(), JConfig.server_port);                                          \/\/InputStream  inStream = socket.getInputStream();                     PrintWriter socketOut;                                          socketOut = new PrintWriter(socket.getOutputStream(), true);                                        socketOut.println(message);                     socket.close();                     System.out.println(&quot;Send: &quot;+i);                     Thread.sleep(100);                                      }             } catch ( IOException | InterruptedException ex) {                 Logger.getLogger(JClientTCPTest.class.getName()).log(Level.SEVERE, null, ex);             }         }     }          class Receiver extends Thread{         JSONObject jsonObj;         JSONParser parser;                  @Override         public void run(){             try {                  ServerSocket serverSocket = new ServerSocket(JConfig.client_port);                 String data = &quot;&quot;;                                  while(true){                     data = &quot;&quot;;                     Socket   socket      = serverSocket.accept();                      InputStream inStream = socket.getInputStream();                      Scanner scanner      = new Scanner(inStream);                                          while(scanner.hasNextLine()){                         data += scanner.nextLine();                     }                     System.out.println(data);                                     }                              } catch (IOException ex) {                 Logger.getLogger(JClientTCPTest.class.getName()).log(Level.SEVERE, null, ex);             }         }     } } <\/code><\/pre>\n<p>  \u0421\u0435\u0440\u0432\u0435\u0440  <\/p>\n<pre><code class=\"java\"> package tasks;  import jsock.message.JInMessages; import jsock.message.JOutMessages; import jsock.task.JClientTask; import models.Users;  \/**  *  * @author padaboo I.B Aleksandrov jetananas@yandex.ru  *\/ public class JTestTask extends JClientTask{      public JTestTask(JInMessages message) {         super(message);     }          @Override     public String[][] rules(){         String[][] rules = {              {&quot;require&quot;,&quot;message&quot;}         };         return rules;     }          @Override     public String rights() {         \/\/String rigths = &quot;user,admin&quot;;         String rigths = &quot;guest&quot;;                  return rigths;     }      @Override     public void action(){         String message   = this.message.json.get(&quot;message&quot;).toString();         System.out.println(message);                String outString = &quot;{\\&quot;message\\&quot;:\\&quot;Test\\&quot;}&quot;;               JOutMessages outMessage = new JOutMessages(this.message.ip,outString);        outMessage.insert();             }      } <\/code><\/pre>\n<p>  1. \u041a\u043b\u0438\u0435\u043d\u0442\u0430 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 json \u0441\u0442\u0440\u043e\u043a\u0443 c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<br \/>  2. \u0417\u0430\u0434\u0430\u0447\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0441\u044b\u043b\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<p>  <b>\u0417\u0430\u0434\u0430\u0447\u0430<\/b><br \/>  \u0417\u0430\u0434\u0430\u0447\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0432 \u043f\u0430\u043f\u043a\u0435 tasks \u0438 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u0430 \u043e\u0442 JClientTask.<br \/>  \u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u043b\u0430\u0441\u0441 JInMessages \u0441 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c.<br \/>  \u0414\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b rules,rights,action.<br \/>  \u0432 rules \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438.<br \/>  \u0432 rights \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u0430\u0432\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<br \/>  \u0432 action \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434.<\/p>\n<p>  <b>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<br \/>  <\/b>  <\/p>\n<pre><code class=\"java\"> String message   = this.message.json.get(&quot;message&quot;).toString(); <\/code><\/pre>\n<p>  <b>\u0421\u0442\u0440\u043e\u043a\u0430 \u043e\u0442\u0432\u0435\u0442\u0430 \u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u043d\u043e\u043a\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c<\/b>  <\/p>\n<pre><code class=\"java\">String outString = &quot;{\\&quot;message\\&quot;:\\&quot;Test\\&quot;}&quot;;        JOutMessages outMessage = new JOutMessages(this.message.ip,outString); outMessage.insert();<\/code><\/pre>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e ip \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 ip \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043b\u0443\u0448\u0430\u0435\u0442 \u0441\u043e\u043a\u0435\u0442 \u0438 \u0436\u0434\u0435\u0442 json \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>  <b>\u041c\u043e\u0434\u0435\u043b\u0438<\/b><br \/>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0444\u0440\u0435\u043c\u0432\u043e\u0440\u043a\u0430 \u043f\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432 \u0431\u0430\u0437\u0435 \u0431\u0443\u0434\u0443\u0442 2 \u0442\u0430\u0431\u043b\u0438\u0446\u044b: Users, Session. \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0430\u0445 \u0441 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438.<br \/>  \u0412\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0432 \u043f\u0430\u043f\u043a\u0435 models, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u044b \u043e\u0442 DBQuery \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0412 \u043a\u043b\u0430\u0441\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <b>\u041f\u0440\u0430\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439<br \/>  <\/b><br \/>  1. \u041f\u0440\u0430\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 rights:guest,user,admin. \u041d\u0435\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u0430 guest. \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f user, \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 rights.<br \/>  <b>\u041f\u0440\u0438\u043c\u0435\u0440: \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443, \u043c\u043e\u0434\u0435\u043b\u0438, \u043f\u0440\u0430\u0432\u0430<\/b><br \/>  <b>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430<br \/>  <\/b>   <\/p>\n<pre><code class=\"java\">@Override     public void action(){                  String email    = this.message.json.get(&quot;email&quot;).toString();                  String password = this.message.json.get(&quot;password&quot;).toString();                  Users users     = new Users();                  boolean isAuth  = users.authorization(email,password);                  String outString;                  if(isAuth){                            String token       = users.getToken();              int   userId       = users.id;                            String ip          = this.message.ip;                            \/\/System.out.println(insertQuery);                            Session session = new Session();                            session.setToken(userId, token,ip);                                          outString = &quot;{\\&quot;token\\&quot;:\\&quot;&quot; + token +&quot;\\&quot;}&quot;;                       }else{              outString = &quot;{\\&quot;error\\&quot;:\\&quot;Incorrect login or password \\&quot;}&quot;;         }                  JOutMessages outMessage = new JOutMessages(this.message.ip,outString);         outMessage.insert();              } <\/code><\/pre>\n<p>  1. \u0412 \u043f\u0440\u0430\u0432\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:email,password.<br \/>  2. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c Users, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<br \/>  3. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0435\u0441\u0441\u0438\u0438 \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d.<br \/>  4. \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0442\u0432\u0435\u0442.<br \/>  5. \u0422\u043e\u043a\u0435\u043d \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0440\u0430\u0432<br \/>  <\/b><\/p>\n<pre><code class=\"java\">  @Override     public void action(){         \/**          * get ip from session and send to open socket                  **\/         System.out.println(&quot;user_id: &quot; + webUser.id + &quot; email: &quot; + webUser.email + &quot; rights: &quot;+ webUser.rights);                   Session session = new Session();         session.findByUserID(12);                  String ip = session.ip;         \/\/all users         \/\/session  connection                  String outString = &quot;{\\&quot;ip_message\\&quot;:\\&quot;send to user by session id\\&quot;}&quot;;                  JOutMessages outMessage = new JOutMessages(ip,outString);         outMessage.insert();              } <\/code><\/pre>\n<p>  1. \u0412 \u043f\u0440\u0430\u0432\u0430\u0445 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c user.<br \/>  2. \u0412 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 token<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u00ab\u043d\u0435 \u0433\u043e\u0441\u0442\u044c\u00bb. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0438\u0449\u0435\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Session, \u043f\u043e user_id \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c Users \u2014 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 webUser.<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c \u043f\u043e user_id \u0432 Session \u0438\u043b\u0438 \u043f\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u044e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 JConnections.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 tasks.JRegistrationTask<br \/>  \u0412\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 \/tests\/.<br \/>  \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f.<br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/318782\/\"> https:\/\/habrahabr.ru\/post\/318782\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a.<br \/>  \u0420\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e \u043e\u043d\u043b\u0430\u0439\u043d 3\u0434 \u0438\u0433\u0440\u0443, \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430 java. \u0414\u043b\u044f 3d \u0431\u044b\u043b \u0432\u044b\u0431\u0440\u0430\u043d \u0434\u0432\u0438\u0436\u043e\u043a jmonkeyengine. <br \/>  \u0410 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438 p2p \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, MVC \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-283272","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=283272"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283272\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}