MCPcopy Create free account
hub / github.com/BombusMod/BombusMod / blockArrived

Method blockArrived

src/main/java/xmpp/extensions/IqPing.java:52–94  ·  view source on GitHub ↗
(JabberDataBlock data)

Source from the content-addressed store, hash-verified

50 }
51
52 public int blockArrived(JabberDataBlock data) {
53 if (!(data instanceof Iq))
54 return BLOCK_REJECTED;
55
56 String type=data.getTypeAttribute();
57 String from=data.getAttribute("from");
58 String id=data.getAttribute("id");
59
60 if (type.equals("result") || type.equals("error")) {
61 if (id.equals(PING)) {
62 StaticData.getInstance().getTheStream().pingSent=false;
63 return BLOCK_PROCESSED;
64 }
65 }
66 if (type.equals("get")) {
67 JabberDataBlock ping=data.getChildBlock(PING);
68 if (ping!=null) {
69 if (ping.getAttribute("xmlns").equals("urn:xmpp:ping")) {
70 Iq reply=new Iq(from, Iq.TYPE_RESULT, id);
71 StaticData.getInstance().getTheStream().send(reply);
72 return BLOCK_PROCESSED;
73 }
74 }
75 }
76 if (type.equals("result")) {
77 if (id.startsWith(_PING_)) {
78 Roster roster=StaticData.getInstance().roster;
79 Contact c=roster.getContact(from, false);
80
81 String pong = pingToString(id.substring(6));
82
83 roster.querysign=false;
84
85 if (pong!=null) {
86 Msg m=new Msg(Msg.MESSAGE_TYPE_SYSTEM, "pong", SR.MS_PING, pong);
87 roster.messageStore(c, m);
88 roster.redraw();
89 }
90 return BLOCK_PROCESSED;
91 }
92 }
93 return BLOCK_REJECTED;
94 }
95
96 private String pingToString(String time) {
97 String timePing=Long.toString((Time.utcTimeMillis()-Long.parseLong(time))/10);

Callers

nothing calls this directly

Calls 12

getInstanceMethod · 0.95
getAttributeMethod · 0.95
getContactMethod · 0.95
pingToStringMethod · 0.95
messageStoreMethod · 0.95
getTypeAttributeMethod · 0.80
getTheStreamMethod · 0.80
getChildBlockMethod · 0.80
getAttributeMethod · 0.45
equalsMethod · 0.45
sendMethod · 0.45
redrawMethod · 0.45

Tested by

no test coverage detected