Package org.telehash.model

Examples of org.telehash.model.Telex


      String response = buffer.getString(decoder);
      int br = response.getBytes().length;
      logger.debug("RECV[{}] from {}: {} bytes: {}", new Object[]{
          session.getId(),
          (InetSocketAddress)session.getRemoteAddress(), br, response});
      Telex telex = (Telex)
          JsonMapper.fromJson(response, TelehashPackage.Literals.TELEX);
      switch (state.getConnectionStatus()) {
      case SEEDING:
        completeBootstrap(session, telex, br);
        break;
View Full Code Here


          } catch (IOException e) {
            logger.error(e.getMessage(), e);
          }
                }
                else{
                    Telex telexOut = tf.createTelex();
                    for (String fieldName : telex.getFieldNames()) {
                      telexOut.with(fieldName, telex.get(fieldName));
                    }
                    telexOut.with("_hop", hop + 1);
                    send(telexOut);
                }
          }
        }
  }
View Full Code Here

          numValid++;
         
          if (state.getConnectionStatus() == ConnectionStatus.CONNECTED) {
         
              // +end ourselves to see if they know anyone closer as a ping
            Telex telexOut = tf.createTelex().withTo(line).withEnd(state.getSelfHash());
             
              // also .see ourselves if we haven't yet, default for now is to participate in the DHT
              if (!line.isAdvertised()) {
                line.setAdvertised(true);
                telexOut.getSee().add(state.getSelfAddress());
              }
             
              // also .tap our hash for +pop requests for NATs
              TapRule tapRule = tf.createTapRule();
              tapRule.setIs(tf.createTelex().withEnd(state.getSelfHash()));
              tapRule.getHas().add("+pop");
              telexOut.getTap().add(tapRule);
              send(telexOut);
          }
      }
     
      if (state.getConnectionStatus() == ConnectionStatus.CONNECTED && numValid == 0
View Full Code Here

              if (line.isSetTapLastAt() && line.getTapLastAt() + 50 > time()) {
                  return; // only tap every 50sec
              }
             
              line.setTapLastAt(time());
              Telex telexOut = (Telex) tf.createTelex().withTo(line)
                .with(".tap", Lists.newArrayList(tapRule)); // tap the closest ipp to our target end
              logger.info("TAPTAP to {} end {} tap {}", new Object[]{
                  line.getAddress(), tapEnd, JsonMapper.toJson(telexOut)});
              send(telexOut);
          }
View Full Code Here

              closestAddrs.add(switchHandler.getAddress())// mark ourselves visible at least once
              line.setAdvertised(true);
          }
         
          if (!closestAddrs.isEmpty()) {
            Telex telexOut = tf.createTelex().withTo(line);
            telexOut.getSee().addAll(closestAddrs);
            switchHandler.send(telexOut);
          }
      }
     
      // this is our .tap, requests to +pop for NATs
View Full Code Here

  }

  private static void sendWallMessage(String msg) {
    logger.info("Wall: {}", msg);
    for (InetSocketAddress addr : handler.getLineAddresses()) {
      Telex telex = (Telex) tf.createTelex().withTo(addr)
        .withEnd(room)
        .with("+guid", System.currentTimeMillis())
        .with("_hop", 1)
        .with("+wall", msg);
      handler.send(telex);
View Full Code Here

            // XXX todo: if we're dialing we'd want to reach out to any of these closer to that $tap_end
            // also check to see if we want them in a bucket
            if (bucketWant(seeAddr, seeHash)) {
               
                // send direct (should open our outgoing to them)
              Telex telexOut = tf.createTelex().withTo(seeAddr)
                .withEnd(switchHandler.getAddressHash());
                switchHandler.send(telexOut);
               
                // send pop signal back to the switch who .see'd us in case the new one is behind a nat
                telexOut = (Telex) tf.createTelex().withTo(recvLine)
View Full Code Here

   * @generated
   */
  protected T doSwitch(int classifierID, EObject theEObject) {
    switch (classifierID) {
    case TelehashPackage.TELEX: {
      Telex telex = (Telex) theEObject;
      T result = caseTelex(telex);
      if (result == null)
        result = caseJsObject(telex);
      if (result == null)
        result = defaultCase(theEObject);
View Full Code Here

  /**
   * Rigourous Test :-)
   * @throws IOException
   */
  public void testSimpleTelex() throws IOException {
    Telex telex = (Telex)
      JsonMapper.fromJson("{\"_to\": \"147.26.10.11:40401\", \"+end\": \"a9993e364706816aba3e25717850c26c9cd0d89d\"}",
        TelehashPackage.Literals.TELEX);
    assertEquals("147.26.10.11", telex.getTo().getAddress().getHostAddress());
    assertEquals(40401, telex.getTo().getPort());
    assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", telex.getEnd().toString());
    assertEquals("a9993e364706816aba3e25717850c26c9cd0d89d", telex.get("+end").toString());
  }
View Full Code Here

  /**
   * Test stuff in the JSON that isn't mapped
   * @throws IOException
   */
  public void testFallThru() throws IOException {
    Telex telex = (Telex)
      JsonMapper.fromJson("{\"foo\": 1, \"bar\": true, \"baz\": {\"a\": [1,2,3]} }",
        TelehashPackage.Literals.TELEX);
    assertEquals(1, ((Integer)telex.get("foo")).intValue());
    assertEquals(true, ((Boolean)telex.get("bar")).booleanValue());
   
    @SuppressWarnings({ "rawtypes", "unchecked" })
    List<Object> a = (List<Object>) ((Map)telex.get("baz")).get("a");
    for (int i = 0; i < 3; i++) {
      assertEquals(i + 1, ((Integer)a.get(i)).intValue());
    }
  }
View Full Code Here

TOP

Related Classes of org.telehash.model.Telex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.