1
나열된 클래스에서 아래 줄을 실행할 때마다 2017.2.0f3 및 2017.2.1f1 버전에서이 오류가 발생했지만 완벽하게 작동합니다. 에서 5.5.0.f3WWW WebRequest UriFormatException : URI 체계는 문자로 시작해야하며 다음 중 하나로 구성되어야합니다.
WWW request = new WWW(m_host, bytes, HashtableToDictionary<string, string>(postHeader));
ERROR :
UriFormatException: URI scheme must start with a letter and must consist of one of alphabet, digits, '+', '-' or '.' character.
System.Uri.Parse (UriKind kind, System.String uriString)
System.Uri.ParseUri (UriKind kind)
System.Uri..ctor (System.String uriString, Boolean dontEscape)
System.Uri..ctor (System.String uriString)
클래스 생성 오류 :
public class ServerRequest<T> : BaseServerRequest
{
public string Game;
public string Content;
[NonSerialized]
public bool Successful;
[NonSerialized]
public ServerResponseData<T> Response;
private string m_host;
private MonoBehaviour owner;
private bool m_finished = false;
private bool m_running = false;
public override object Current
{
get
{
return null;
}
}
public ServerRequest(Dictionary<string, object> content, string game, string host, MonoBehaviour owner)
{
SetContent(content);
Game = game;
m_host = host;
this.owner = owner;
}
public IEnumerator Process()
{
Debug.Log("Sending Data...");
UTF8Encoding encoding = new UTF8Encoding();
string json = TinyJson.JSONParser.ToJson(this);
Debug.Log("Sending Json...\n" + json);
byte[] bytes = encoding.GetBytes(json);
Hashtable postHeader = new Hashtable();
postHeader.Add("Content-Type", "text/json");
postHeader.Add("Content-Length", json);
WWW request = new WWW(m_host, bytes, HashtableToDictionary<string, string>(postHeader));
yield return request;
if (request == null)
{
Successful = false;
}
else if (request.error != null)
{
Successful = false;
Debug.LogError(request.error);
}
else
{
Successful = true;
Debug.Log("Response Text: " + request.text);
string responseJson1 = request.text.ReplaceAll("\\n", "\\\\n").ReplaceAll("\\t", "\\\\t");
Debug.Log("Response Text2: " + responseJson1);
Response = TinyJson.JSONParser.FromJson<ServerResponseData<T>>(responseJson1);
Debug.Log("Response: ");
Debug.Log("\tContent: " + Response.Content);
Debug.Log("\tSuccessful: " + Response.Successful);
Debug.Log("\tMessage: " + Response.Message);
}
m_finished = true;
}
public static Dictionary<K, V> HashtableToDictionary<K, V>(Hashtable table)
{
return table
.Cast<DictionaryEntry>()
.ToDictionary(kvp => (K)kvp.Key, kvp => (V)kvp.Value);
}
public override string ToString()
{
return string.Format("Response: Successfull = {0}, Content = {1}", Successful, Response);
}
public override string ToJson()
{
return string.Format("{{ \"Game\": \"{0}\", \"Content\": {1} }}", Game, Content);
}
public override bool MoveNext()
{
if (!m_running)
{
m_running = true;
owner.StartCoroutine(Process());
}
return !m_finished;
}
public override void Reset()
{
// Nope
}
public void SetContent(Dictionary<string, object> content)
{
Content = TinyJson.JSONParser.ToJson(content);
}
}
이전에이 오류가 발생하여 고칠 수 있었습니까?
URI 방식입니다 당신이, (이 경우 m_host''의 값)에 – AVAVT
계획을 요청을 전송하고있는 URL 예 : 'http'또는 'https'입니다. 물론 웹에는 http 또는 https를 사용한다고 상상할 수도 있지만 다른 여러 구성표가 존재합니다. – john
그리고 오늘 이미 다른 사람에게 말했듯이, JSON에 담고있는 내용이 확실하지 않다면 시리얼 라이저를 사용하는 것이 가장 좋습니다. 갑자기'Game'이나'Content'가 따옴표를 포함하면 JSON이 깨질 것입니다. – john