public write ( byte arg0, int arg1, int arg2 ) : void | ||
arg0 | byte | |
arg1 | int | |
arg2 | int | |
Результат | void |
public override void writePacketData(DataOutputStream dataoutputstream) { dataoutputstream.writeInt(xLocation); dataoutputstream.writeShort(yLocation); dataoutputstream.writeInt(zLocation); dataoutputstream.write(instrumentType); dataoutputstream.write(pitch); }
public override void writePacketData(DataOutputStream dataoutputstream) { dataoutputstream.writeInt(xPosition); dataoutputstream.write(yPosition); dataoutputstream.writeInt(zPosition); dataoutputstream.write(type); dataoutputstream.write(metadata); }
public override void writePacketData(DataOutputStream dataoutputstream) { dataoutputstream.writeInt(entityId); dataoutputstream.writeInt(xPosition); dataoutputstream.writeInt(yPosition); dataoutputstream.writeInt(zPosition); dataoutputstream.write(yaw); dataoutputstream.write(pitch); }
public override void writePacketData(DataOutputStream dataoutputstream) { dataoutputstream.writeInt(xPosition); dataoutputstream.write(yPosition); dataoutputstream.writeInt(zPosition); dataoutputstream.write(direction); if (itemStack == null) { dataoutputstream.writeShort(-1); } else { dataoutputstream.writeShort(itemStack.itemID); dataoutputstream.writeByte(itemStack.stackSize); dataoutputstream.writeShort(itemStack.getItemDamage()); } }
public override void writePacketData(DataOutputStream dataoutputstream) { dataoutputstream.writeInt(xPosition); dataoutputstream.writeInt(yPosition); dataoutputstream.write(mode ? 1 : 0); }
public static void writePacket(Packet packet, DataOutputStream dataoutputstream) { dataoutputstream.write(packet.getPacketId()); packet.writePacketData(dataoutputstream); }
public override void writePacketData(DataOutputStream dataoutputstream) { dataoutputstream.writeInt(xPosition); dataoutputstream.writeInt(zPosition); dataoutputstream.writeShort((short) size); for (int i = 0; i < size; i++) { dataoutputstream.writeShort(coordinateArray[i]); } dataoutputstream.write(typeArray); dataoutputstream.write(metadataArray); }
static int writeUTF(String str, DataOutputStream @out) { int strlen = str.length(); int utflen = 0; int c, count = 0; /* use charAt instead of copying String to char array */ int i; for (i = 0; i < strlen; i++) { c = str.charAt(i); if ((c >= 0x0001) && (c <= 0x007F)) { utflen++; } else if (c > 0x07FF) { utflen += 3; } else { utflen += 2; } } if (utflen > 65535) throw new Exception( "encoded string too long: " + utflen + " bytes"); byte[] bytearr = null; if (@out is DataOutputStream) { DataOutputStream dos = (DataOutputStream)@out; if(dos.bytearr == null || (dos.bytearr.Length < (utflen+2))) dos.bytearr = new byte[(utflen*2) + 2]; bytearr = dos.bytearr; } else { bytearr = new byte[utflen+2]; } bytearr[count++] = (byte) ((int)(((uint)utflen) >> 8) & 0xFF); bytearr[count++] = (byte) ((int)(((uint)utflen) >> 0) & 0xFF); i=0; for (i=0; i<strlen; i++) { c = str.charAt(i); if (!((c >= 0x0001) && (c <= 0x007F))) break; bytearr[count++] = (byte) c; } for (;i < strlen; i++){ c = str.charAt(i); if ((c >= 0x0001) && (c <= 0x007F)) { bytearr[count++] = (byte) c; } else if (c > 0x07FF) { bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F)); bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F)); bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); } else { bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F)); bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F)); } } @out.write(bytearr, 0, utflen+2); return utflen + 2; }
public byte[] UploadValues(Uri address, NameValueCollection data) { // http://www.xyzws.com/Javafaq/how-to-use-httpurlconnection-post-data-to-web-server/139 // http://stackoverflow.com/questions/3038176/httpurlconnection-does-not-read-the-whole-respnse var addressString = address.ToString(); //Console.WriteLine("enter UploadValues " + new { addressString }); // String urlParameters = //"fName=" + URLEncoder.encode("???", "UTF-8") + //"&lName=" + URLEncoder.encode("???", "UTF-8") var m = new MemoryStream(); try { //Console.WriteLine("before urlParameters"); #region urlParameters var urlParameters = new StringBuilder(); //Implementation not found for type import : //type: System.Collections.Specialized.NameObjectCollectionBase //method: KeysCollection get_Keys() //Did you forget to add the [Script] attribute? //Please double check the signature! //foreach (string key in data.Keys) foreach (string key in data.AllKeys) { if (urlParameters.Length > 0) urlParameters.Append("&"); urlParameters.Append( key + "=" + URLEncoder.encode(data[key], "UTF-8") ); } #endregion //Console.WriteLine("after urlParameters"); // Y:\staging\web\java\ScriptCoreLibJava\BCLImplementation\System\Net\__WebClient___c__DisplayClass2.java:60: error: unreported exception UnsupportedEncodingException; must be caught or declared to be thrown //builder0.Append(__String.Concat(string1, "=", URLEncoder.encode(this.data.get_Item(string1), "UTF-8"))); // ^ //Console.WriteLine( // new { addressString } //); var url = new java.net.URL(addressString); // https://developer.android.com/training/articles/security-ssl.html var connection = (HttpURLConnection)url.openConnection(); var https = connection as HttpsURLConnection; if (https != null) { Console.WriteLine(new { https }); } connection.setUseCaches(false); connection.setDoInput(true); connection.setDoOutput(true); connection.setChunkedStreamingMode(0); // Numeric status code, 403: Forbidden // UserAgent: Java/1.7.0_45 //HtmlElement: Access denied | my.monese.com used CloudFlare to restrict access</title> //- Http: Request, POST /xml/GetCurrencyRateBasedOnString // Command: POST // + URI: /xml/GetCurrencyRateBasedOnString // ProtocolVersion: HTTP/1.1 // + ContentType: application/x-www-form-urlencoded // Cache-Control: no-cache // Pragma: no-cache // UserAgent: Java/1.7.0_45 // Host: my.monese.com // Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 // Connection: keep-alive // ContentLength: 106 // HeaderEnd: CRLF //- Http: Request, POST /xml/GetCurrencyRateBasedOnString // Command: POST // + URI: /xml/GetCurrencyRateBasedOnString // ProtocolVersion: HTTP/1.1 // + ContentType: application/x-www-form-urlencoded // Host: my.monese.com // ContentLength: 106 // Expect: 100-continue // Connection: Keep-Alive // HeaderEnd: CRLF // error { Message = Connection timed out: connect, StackTrace = java.net.ConnectException: Connection timed out: connect //at java.net.DualStackPlainSocketImpl.connect0(Native Method) connection.setRequestMethod("POST"); // https://issues.jenkins-ci.org/browse/JENKINS-21033?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel // https://github.com/scalaj/scalaj-http/issues/27 connection.setRequestProperty("User-Agent", "WebClient"); connection.setRequestProperty("Accept", "application/xml"); connection.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded" ); var bytes = Encoding.UTF8.GetBytes( urlParameters.ToString() ); connection.setRequestProperty("Content-Length", "" + bytes.Length); //connection.setRequestProperty("Content-Language", "en-US"); if (Headers != null) { foreach (string key in Headers.AllKeys) connection.addRequestProperty(key, Headers[key]); } //Console.WriteLine("before writeBytes " + new { bytes.Length }); #region Send request var wr = new DataOutputStream( connection.getOutputStream()); wr.write((sbyte[])(object)bytes); //wr.writeBytes(urlParameters.ToString()); wr.flush(); #endregion //error { Message = Server returned HTTP response code: 403 for URL: // at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) // at ScriptCoreLibJava.BCLImplementation.System.Net.__WebClient___c__DisplayClass2._UploadValuesAsync_b__1(__WebClient___c__DisplayClass2.java:82) //Console.WriteLine("before Read "); // X:\jsc.svn\core\ScriptCoreLibJava\BCLImplementation\System\Net\WebClient.cs //Get Response // namespace java.io var asw = Stopwatch.StartNew(); var ResponseCode = connection.getResponseCode(); //Console.WriteLine("awaiting for input..."); var xis = connection.getInputStream().ToNetworkStream(); var buffer = new byte[0x4000]; //var buffer = new byte[0x10000]; // do we have to wait on android? //Console.WriteLine(new { xis.DataAvailable, asw.ElapsedMilliseconds }); //var ss = xis.Read(buffer, 0, 0); //Console.WriteLine(new { ss, xis.DataAvailable, asw.ElapsedMilliseconds }); //I/System.Console( 7821): { DataAvailable = false, ElapsedMilliseconds = 8278 } //I/System.Console( 7821): awaiting for input... { s = 2730 } //I/System.Console( 7821): awaiting for input... { s = 1340 } //I/System.Console( 7821): awaiting for input... { s = 438 } //I/System.Console( 7821): awaiting for input... { s = -1 } //I/System.Console( 7821): bytes: {{ Length = 4508 }} //I/System.Console( 7821): source: {{ Length = 4496 }} //I/System.Console(10970): { DataAvailable = true, ElapsedMilliseconds = 236 } //I/System.Console(10970): { ss = 0, DataAvailable = true, ElapsedMilliseconds = 237 } //var ok = true; while (xis.DataAvailable) //while (ok) { var s = xis.Read(buffer, 0, buffer.Length); //Console.WriteLine("awaiting for input... " + new { s }); //if (s < 0) //{ // ok = false; //} //else if (s > 0) m.Write(buffer, 0, s); } //wr.close(); //xis.Close(); if (connection != null) { connection.disconnect(); } //xis.Read( //xis.readall } catch (Exception ex) { //error { Message = failed to connect to apps.emta.ee/213.184.49.80 (port 80): connect failed: ETIMEDOUT (Connection timed out), StackTrace = java.net.ConnectException: failed to connect to apps.emta.ee/213.184.49.80 (port 80): connect failed: ETIMEDOUT (Connection timed out) // at libcore.io.IoBridge.connect(IoBridge.java:114) // at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) // at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459) // at java.net.Socket.connect(Socket.java:843) // at com.android.okhttp.internal.Platform.connectSocket(Platform.java:131) // at com.android.okhttp.Connection.connect(Connection.java:101) // at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294) // at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255) // at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206) // at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345) // at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89) // at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197) // ? Console.WriteLine("error " + new { ex.Message, ex.StackTrace }); } //Thread.Sleep(666); var Result = m.ToArray(); return Result; }
static int writeUTF(String str, DataOutputStream @out) { int strlen = str.length(); int utflen = 0; int c, count = 0; /* use charAt instead of copying String to char array */ int i; for (i = 0; i < strlen; i++) { c = str.charAt(i); if ((c >= 0x0001) && (c <= 0x007F)) { utflen++; } else if (c > 0x07FF) { utflen += 3; } else { utflen += 2; } } if (utflen > 65535) { throw new Exception( "encoded string too long: " + utflen + " bytes"); } byte[] bytearr = null; if (@out is DataOutputStream) { DataOutputStream dos = (DataOutputStream)@out; if (dos.bytearr == null || (dos.bytearr.Length < (utflen + 2))) { dos.bytearr = new byte[(utflen * 2) + 2]; } bytearr = dos.bytearr; } else { bytearr = new byte[utflen + 2]; } bytearr[count++] = (byte)((int)(((uint)utflen) >> 8) & 0xFF); bytearr[count++] = (byte)((int)(((uint)utflen) >> 0) & 0xFF); i = 0; for (i = 0; i < strlen; i++) { c = str.charAt(i); if (!((c >= 0x0001) && (c <= 0x007F))) { break; } bytearr[count++] = (byte)c; } for (; i < strlen; i++) { c = str.charAt(i); if ((c >= 0x0001) && (c <= 0x007F)) { bytearr[count++] = (byte)c; } else if (c > 0x07FF) { bytearr[count++] = (byte)(0xE0 | ((c >> 12) & 0x0F)); bytearr[count++] = (byte)(0x80 | ((c >> 6) & 0x3F)); bytearr[count++] = (byte)(0x80 | ((c >> 0) & 0x3F)); } else { bytearr[count++] = (byte)(0xC0 | ((c >> 6) & 0x1F)); bytearr[count++] = (byte)(0x80 | ((c >> 0) & 0x3F)); } } @out.write(bytearr, 0, utflen + 2); return(utflen + 2); }
public override void writePacketData(DataOutputStream dataoutputstream) { dataoutputstream.write(onGround ? 1 : 0); }