private void establishConnection() throws IOException { Socket socket = new Socket(connectionInfo.getHostName(), connectionInfo.getPortNum()); slaveSocket = new SlaveClientSocket(session.getID(), socket, new MyListener()); slaveSocket.initialize(); }
private void takeOffHold() { try { session.send( client, new VoiceChatHoldMessage(group, myPresenceInfo, false, 1, client.getCOSName())); setMode(Mode.IN_PROGRESS); } catch (IllegalStateException e) { leave(); } }
private void setHoldVolume(float volume) { try { session.send( client, new VoiceChatHoldMessage(group, myPresenceInfo, true, volume, client.getCOSName())); } catch (IllegalStateException e) { leave(); } }
private void leave() { session.send(client, new VoiceChatLeaveMessage(group, myPresenceInfo, client.getCOSName())); addHUDComponent.setVisible(false); addHUDPanelList.remove(this); if (addModeAddHUDComponent != null) { addModeAddHUDComponent.setVisible(false); } CallAnimator.stopCallAnswerAnimation(client); }
private void setHoldMode() { clearPanel(); showHoldPanel(true); float volume = holdPanel.getHoldVolume(); try { session.send( client, new VoiceChatHoldMessage(group, myPresenceInfo, true, volume, client.getCOSName())); } catch (IllegalStateException e) { leave(); } CallAnimator.stopCallAnswerAnimation(client); }
private void setInProgressMode() { clearPanel(); showAddUserPanel(true, true); showInProgressButtons(true); holdOtherCalls(); if (addUserPanel.getPrivacy().equals(ChatType.PRIVATE)) { CallAnimator.animateCallAnswer(client); String COSName = client.getCOSName(); if (COSName != null) { session.send(client, new VoiceChatHoldMessage(group, myPresenceInfo, false, 1, COSName)); } } else { CallAnimator.stopCallAnswerAnimation(client); } }
private void initialHandshake() throws EOFException { String userName = session.getUserID().getUsername(); int strLen = userName.length(); // Inform the server that we have connected by sending a hello message // with the name of this user byte[] helloBuf = new byte[Proto.ClientMessageType.HELLO.size() + strLen + Proto.SIGNATURE_SIZE]; helloBuf[0] = (byte) Proto.ClientMessageType.HELLO.ordinal(); helloBuf[1] = (byte) 0; // pad helloBuf[2] = (byte) ((strLen >> 8) & 0xff); helloBuf[3] = (byte) (strLen & 0xff); System.arraycopy(userName.getBytes(), 0, helloBuf, 4, strLen); try { slaveSocket.send(sign(helloBuf)); } catch (IOException ex) { throw new RuntimeException(ex); } AppXrw.logger.info("Broadcast slave Hello message for user " + userName); // Get the welcome message from the server. This contains the client id // Note: because the master hub broadcasts to all slaves, there is a chance // there might be irrelevant messages queued up for this // slave. These should be ignored. This come from the fact that it takes // some time after the slave joins the connection for the master to become // aware of it and to compose and send the welcome message. During this time // if there are any incoming messages from the X server they will be // forwarded to this slave even if it has not yet been officially welcomed. // Since the content of these messages will be reflected in the welcome message // and the slave can't really do anything until it is welcomed we need // to ignore these messages. ServerMessageType type = null; do { type = getMessageType(); } while (type != ServerMessageType.WELCOME); // TODO: eventually we should add a timeout // Skip 3 bytes of pad bufQueue.nextByte(); bufQueue.nextShort(); clientId = bufQueue.nextInt(); client.setClientId(clientId); windowParents.clear(); // Read the initial window state synchronization // part of the welcome message int numWins = bufQueue.nextInt(); AppXrw.logger.info("numWins = " + numWins); for (int i = 0; i < numWins; i++) { syncWindowStateNext(); } // All windows have been defined. Now assign the parents for (WindowXrw win : windowParents.keySet()) { Integer parentWid = windowParents.get(win); if (parentWid != null) { WindowXrw parentWin = client.lookupWindow(parentWid.intValue()); win.setParent(parentWin); } } windowParents.clear(); client.updateSlaveWindows(); }