public synchronized void send(String msg) { try { streamOut.writeUTF(msg); } catch (IOException ioe) { System.err.println("Sending error: " + ioe.getMessage()); System.exit(0); } }
/** * It gets the length of the key * * @param key specify the key whose length will be calculated. Input parameter. * @return return the length of the key * @exception KeyNotMatchException key is neither StringKey nor IntegerKey * @exception IOException error from the lower layer */ protected static final int getKeyLength(KeyClass key) throws KeyNotMatchException, IOException { if (key instanceof StringKey) { OutputStream out = new ByteArrayOutputStream(); DataOutputStream outstr = new DataOutputStream(out); outstr.writeUTF(((StringKey) key).getKey()); return outstr.size(); } else if (key instanceof IntegerKey) return 4; else throw new KeyNotMatchException(null, "key types do not match"); }
private void SignInButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_SignInButtonActionPerformed /* username i password spojit u jedan string s delimiterom " ", prije toga nadodat kljucnu rijec "log" taj string se parsira na strani servera i server provjerava jel zadovoljava username i password (odgovor od servera slusa LoginThread koji salje odgovor Login-u preko handle metode) */ String username = UsernameLogin.getText(); String password = PasswordLogin.getText(); String user_pass = "******" + " " + username + " " + password; try { streamOut.writeUTF(user_pass); } catch (IOException ioe) { System.err.println("Sending error: " + ioe.getMessage()); System.exit(0); } } // GEN-LAST:event_SignInButtonActionPerformed