2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 13:33:13 +00:00
This commit is contained in:
2020-01-26 14:30:39 +03:00
parent 5f4660fde2
commit 61a1683c26
22 changed files with 409 additions and 346 deletions

View File

@ -610,8 +610,10 @@ namespace Esyur.Net.IIP
else
{
//Console.WriteLine("User not found");
//SendParams((byte)0xc0, (byte)1, (ushort)14, DC.ToBytes("User not found"));
SendParams().AddUInt8(0xc0).AddUInt8(1).AddUInt16(14).AddString("User not found").Done();
SendParams().AddUInt8(0xc0)
.AddUInt8((byte)ExceptionCode.UserNotFound)
.AddUInt16(14)
.AddString("User not found").Done();
}
});
@ -649,9 +651,11 @@ namespace Esyur.Net.IIP
else
{
//Global.Log("auth", LogType.Warning, "U:" + RemoteUsername + " IP:" + Socket.RemoteEndPoint.Address.ToString() + " S:DENIED");
//Console.WriteLine("Incorrect password");
//SendParams((byte)0xc0, (byte)1, (ushort)5, DC.ToBytes("Error"));
SendParams().AddUInt8(0xc0).AddUInt8(1).AddUInt16(5).AddString("Error").Done();
SendParams().AddUInt8(0xc0)
.AddUInt8((byte)ExceptionCode.AccessDenied)
.AddUInt16(13)
.AddString("Access Denied")
.Done();
}
}
});
@ -729,9 +733,9 @@ namespace Esyur.Net.IIP
{
SendParams()
.AddUInt8(0xc0)
.AddUInt8(1)
.AddUInt16(5)
.AddString("Error")
.AddUInt8((byte)ExceptionCode.ChallengeFailed)
.AddUInt16(16)
.AddString("Challenge Failed")
.Done();
//SendParams((byte)0xc0, 1, (ushort)5, DC.ToBytes("Error"));
@ -789,7 +793,6 @@ namespace Esyur.Net.IIP
catch (Exception ex)
{
Console.WriteLine(ex);
Console.Beep();
}
finally
{
@ -830,7 +833,7 @@ namespace Esyur.Net.IIP
var sock = new TCPSocket();
sock.Connect(domain, port).Then((x)=> {
sock.Connect(address, port).Then((x)=> {
Assign(sock);
//rt.trigger(true);
}).Error((x) =>
@ -849,7 +852,7 @@ namespace Esyur.Net.IIP
/// </summary>
/// <param name="resource">Resource.</param>
/// <returns></returns>
public bool Put(IResource resource)
public async AsyncReply<bool> Put(IResource resource)
{
if (Codec.IsLocalResource(resource, this))
resources.Add((resource as DistributedResource).Id, (DistributedResource)resource);

View File

@ -1097,6 +1097,10 @@ namespace Esyur.Net.IIP
var ft = r.Instance.Template.GetFunctionTemplateByIndex(index);
if (ft != null)
{
// un hold the socket to send data immediately
this.Socket.Unhold();
if (r is DistributedResource)
{
var rt = (r as DistributedResource)._InvokeByArrayArguments(index, arguments);
@ -1163,7 +1167,8 @@ namespace Esyur.Net.IIP
}
catch (Exception ex)
{
SendError(ErrorType.Exception, callback, 0, ex.InnerException.ToString());
SendError(ErrorType.Exception, callback, 0,
ex.InnerException != null ? ex.InnerException.ToString() : ex.ToString());
return;
}
@ -1171,12 +1176,18 @@ namespace Esyur.Net.IIP
{
var enu = rt as System.Collections.IEnumerable;
foreach (var v in enu)
SendChunk(callback, v);
SendReply(IIPPacket.IIPPacketAction.InvokeFunctionArrayArguments, callback)
.AddUInt8((byte)DataType.Void)
.Done();
try
{
foreach (var v in enu)
SendChunk(callback, v);
SendReply(IIPPacket.IIPPacketAction.InvokeFunctionArrayArguments, callback)
.AddUInt8((byte)DataType.Void)
.Done();
}
catch(Exception ex)
{
SendError(ErrorType.Exception, callback, 0, ex.ToString());
}
}
else if (rt is Task)
@ -1254,6 +1265,9 @@ namespace Esyur.Net.IIP
var ft = r.Instance.Template.GetFunctionTemplateByIndex(index);
if (ft != null)
{
// un hold the socket to send data immediately
this.Socket.Unhold();
if (r is DistributedResource)
{
var rt = (r as DistributedResource)._InvokeByNamedArguments(index, namedArgs);
@ -1323,12 +1337,19 @@ namespace Esyur.Net.IIP
{
var enu = rt as System.Collections.IEnumerable;
foreach (var v in enu)
SendChunk(callback, v);
try
{
foreach (var v in enu)
SendChunk(callback, v);
SendReply(IIPPacket.IIPPacketAction.InvokeFunctionNamedArguments, callback)
.AddUInt8((byte)DataType.Void)
.Done();
SendReply(IIPPacket.IIPPacketAction.InvokeFunctionNamedArguments, callback)
.AddUInt8((byte)DataType.Void)
.Done();
}
catch (Exception ex)
{
SendError(ErrorType.Exception, callback, 0, ex.ToString());
}
}
else if (rt is Task)
{