using UnityEngine;
using BestHTTP;
public class HttpAuthorNliki : MonoBehaviour {
public GameObject Obj;
void Start () {
//网上可以随意找一个图片的地址
new HTTPRequest(new System.Uri("http://www.nliki.com/nliki.png"), (request, response) => {
var tex = new Texture2D(0, 0);
tex.LoadImage(response.Data);
this.Obj.GetComponent().material.mainTexture = tex;
}).Send();
}
}
从WWW切换 你可以在StartCoroutine调用的帮助下生成HTTPRequest:
using UnityEngine;
using System.Collections;
using BestHTTP;
public class HttpAuthorNliki : MonoBehaviour
{
void Start()
{
StartCoroutine(UseHTTPRequest());
}
IEnumerator UseHTTPRequest()
{
HTTPRequest request = new HTTPRequest(new System.Uri("http://www.nliki.com"));
request.Send();
//只有当请求完成时才会调用Debug.Log。通过这种方式,您不必提供回调函数(若想也可以提供回调函数)。
yield return StartCoroutine(request);
Debug.Log("Request finished! Downloaded Data:" + request.Response.DataAsText);
}
}
var request = new HTTPRequest(new System.Uri("http://yourserver.com/bigfile"), (req, resp) => {
List fragments = resp.GetStreamedFragments();
// Write out the downloaded data to a file:
using (FileStream fs = new FileStream("pathToSave", FileMode.Append))
foreach (byte[] data in fragments) fs.Write(data, 0, data.Length);
if (resp.IsStreamingFinished) Debug.Log("Download finished!");
});
request.UseStreaming = true;
request.StreamFragmentSize = 1 * 1024 * 1024;// 1 megabyte
request.DisableCache = true;// already saving to a file, so turn off caching
request.Send();
// Delete cache entries that weren’t accessed in the last two weeks, then
// delete entries to keep the size of the cache under 50 megabytes, starting with the oldest. HTTPCacheService.BeginMaintainence(new HTTPCacheMaintananceParams(TimeSpan.FromDays(14), 50 * 1024 * 1024)); Cookies
public class HttpAuthorNliki : MonoBehaviour
{
void Start()
{
var request = new HTTPRequest(new System.Uri("address"), OnFinished);
request.OnProgress = OnDownloadProgress;
request.Send();
}
void OnFinished(HTTPRequest originalRequest, HTTPResponse response) {
//TODO:
}
void OnDownloadProgress(HTTPRequest request, int downloaded, int downloadLength) {
//TODO:
float progressPercent = (downloaded / (float)length) * 100.0f;
Debug.Log("Downloaded: " + progressPercent.ToString("F2") + "%");
}
}
终止请求 (Aborting a Request )
您可以通过调用HTTPRequest对象的abort()函数来中止正在进行的请求:
request = new HTTPRequest(new System.Uri("http://yourserver.com/bigfile"), (req, resp) => {
//TODO:
});
request.Send();
// And after some time:
request.Abort();
public class HttpAuthorNliki : MonoBehaviour
{
void Start()
{
string url = "http://yourUrl";
HTTPRequest request = new HTTPRequest(new Uri(url), (req, resp) =>{
switch (req.State)
{ // The request finished without any problem.
case HTTPRequestStates.Finished:
Debug.Log("Request Finished Successfully!\n" + resp.DataAsText);
break;
// The request finished with an unexpected error. // The request's Exception property may contain more information about the error.
case HTTPRequestStates.Error:
Debug.LogError("Request Finished with Error! " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception"));
break;
// The request aborted, initiated by the user.
case HTTPRequestStates.Aborted:
Debug.LogWarning("Request Aborted!");
break;
// Ceonnecting to the server timed out.
case HTTPRequestStates.ConnectionTimedOut:
Debug.LogError("Connection Timed Out!");
break;
// The request didn't finished in the given time.
case HTTPRequestStates.TimedOut:
Debug.LogError("Processing the request Timed Out!");
break;
}
});
// Very little time, for testing purposes:
//request.ConnectTimeout = TimeSpan.FromMilliseconds(2);
request.Timeout = TimeSpan.FromSeconds(5);
request.DisableCache = true; request.Send();
}
}
var webSocket = new WebSocket(new Uri("wss://html5......")); 在这一步之后,我们可以注册我们的事件处理程序到几个事件: ● OnOpen事件: 在建立到服务器的连接时调用。在此事件之后,WebSocket的IsOpen属性将为True,直到我们或服务器关闭连接或发生错误。
// Sending out text messages:
webSocket.Send("Message to the Server");
// Sending out binary messages:
byte[] buffer = new byte[length];
//fill up the buffer with data
webSocket.Send(buffer);
Socket nsp = manager["/customNamespace"];
// the same as this methode:
Socket nsp = manager.GetSocket("/customNamespace");
首先访问名称空间将启动内部连接进程。
订阅和接收事件(Subscribing and receiving events) 您可以订阅预定义的和自定义的事件。预定义的事件有“connect”、“connected”、“event”、“disconnect”、“reconnect”、“reconnection”、“reconnect_try”、“reconnect_failed”、“error”。自定义事件是程序员定义的事件,服务器将发送给客户机。您可以通过调用套接字的On函数订阅事件:
// Send a custom event to the server with two parameters
manager.Socket.Emit("message", "userName", "message");
// Send an event and define a callback function that will be called as an
// acknowledgement of this event
manager.Socket.Emit("custom event", OnAckCallback, "param 1", "param 2");
void OnAckCallback(Socket socket, Packet originalPacket, params object[] args)
{
Debug.Log("OnAckCallback!");
}
// Subscribe to the "frame" event, and set the autoDecodePayload flag to false
Socket.On("frame", OnFrame, /*autoDecodePayload:*/ false);
void OnFrame(Socket socket, Packet packet, params object[] args)
{
// Use the Attachments property as before
texture.LoadImage(packet.Attachments[0]);
}
Socket.On("frame", OnFrame, /*autoDecodePayload:*/ false);
void OnFrame(Socket socket, Packet packet, params object[] args)
{
// Replace the Json object with the index
packet.ReconstructAttachmentAsIndex();
// now, decode the Payload to an object[]
args = packet.Decode(socket.Manager.Encoder);
// args now contains only an index number (probably 0)
byte[] data = packet.Attachments[Convert.ToInt32(args[0])];
texture.LoadImage(data);
}
using LitJson;
public sealed class LitJsonEncoder : IJsonEncoder {
public List Decode(string json)
{
JsonReader reader = new JsonReader(json);
return JsonMapper.ToObject>(reader);
}
public string Encode(List obj) {
JsonWriter writer = new JsonWriter();
JsonMapper.ToJson(obj, writer); return writer.ToString();
}
}
分页显示一直是web开发中一大烦琐的难题,传统的网页设计只在一个JSP或者ASP页面中书写所有关于数据库操作的代码,那样做分页可能简单一点,但当把网站分层开发后,分页就比较困难了,下面是我做Spring+Hibernate+Struts2项目时设计的分页代码,与大家分享交流。
1、DAO层接口的设计,在MemberDao接口中定义了如下两个方法:
public in
/*
*使用对象类型
*/
--建立和使用简单对象类型
--对象类型包括对象类型规范和对象类型体两部分。
--建立和使用不包含任何方法的对象类型
CREATE OR REPLACE TYPE person_typ1 as OBJECT(
name varchar2(10),gender varchar2(4),birthdate date
);
drop type p
what 什么
your 你
name 名字
my 我的
am 是
one 一
two 二
three 三
four 四
five 五
class 班级,课
six 六
seven 七
eight 八
nince 九
ten 十
zero 零
how 怎样
old 老的
eleven 十一
twelve 十二
thirteen
spring security 3中推荐使用BCrypt算法加密密码了,以前使用的是md5,
Md5PasswordEncoder 和 ShaPasswordEncoder,现在不推荐了,推荐用bcrpt
Bcrpt中的salt可以是随机的,比如:
int i = 0;
while (i < 10) {
String password = "1234
1.前言。
如题。
2.代码
(1)单表查重复数据,根据a分组
SELECT m.a,m.b, INNER JOIN (select a,b,COUNT(*) AS rank FROM test.`A` A GROUP BY a HAVING rank>1 )k ON m.a=k.a
(2)多表查询 ,
使用改为le