예제 #1
0
 private static void WriteFile(IntPtr info)
 {
     ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments, value) =>
     {
         NSJSInt32 count  = null;
         NSJSInt32 offset = null;
         if (arguments.Length == 2)
         {
             count = arguments[1] as NSJSInt32;
         }
         else if (arguments.Length > 2)
         {
             offset = arguments[1] as NSJSInt32;
             count  = arguments[2] as NSJSInt32;
         }
         int ofs  = offset == null ? 0 : offset.Value;
         int size = count == null ? value.Length : count.Value;
         if (ofs < 0)
         {
             ofs = 0;
         }
         if (size < 0)
         {
             size = 0;
         }
         arguments.SetReturnValue(response.WriteFile(value, ofs, size));
     });
 }
예제 #2
0
 private static void Close(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) =>
     {
         websocket.Close();
         arguments.SetReturnValue(ObjectAuxiliary.RemoveInKeyValueCollection(arguments.This));
     });
 }
예제 #3
0
 private static void Close(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) =>
     {
         server.Stop();
         ObjectAuxiliary.RemoveInKeyValueCollection(arguments.This);
     });
 }
예제 #4
0
 public static void BeginTransaction(IntPtr info)
 {
     ObjectAuxiliary.Call <DATATableGateway>(info, (gateway, arguments) =>
     {
         IDbTransaction transaction = gateway.CreateTransaction();
         NSJSObject objective       = DatabaseTransaction.New(arguments.VirtualMachine, transaction);
         arguments.SetReturnValue(objective);
     });
 }
예제 #5
0
 private static void AddHeader(IntPtr info)
 {
     ObjectAuxiliary.Call(info, (HTTPResponse response, NSJSFunctionCallbackInfo arguments, NSJSValue solt0) =>
     {
         string value = ValueAuxiliary.ToString(arguments.Length > 1 ? arguments[1] : null);
         string name  = ValueAuxiliary.ToString(solt0);
         arguments.SetReturnValue(response.AppendHeader(name, value));
     });
 }
예제 #6
0
 private static void SetCookie(IntPtr info)
 {
     ObjectAuxiliary.Call(info, (HTTPResponse response, NSJSFunctionCallbackInfo arguments, NSJSValue solt0) =>
     {
         bool success  = false;
         Cookie cookie = ObjectAuxiliary.ToCookie(solt0);
         if (cookie != null)
         {
             success = response.SetCookie(cookie);
         }
         arguments.SetReturnValue(success);
     });
 }
예제 #7
0
 private static void Open(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) =>
     {
         try
         {
             websocket.Open();
         }
         catch (Exception exception)
         {
             Throwable.Exception(arguments.VirtualMachine, exception);
         }
     });
 }
예제 #8
0
 private static void Start(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) =>
     {
         try
         {
             server.Start();
         }
         catch (Exception exception)
         {
             Throwable.Exception(arguments.VirtualMachine, exception);
         }
     });
 }
예제 #9
0
파일: Mail.cs 프로젝트: liulilittle/nsjs
 private static void InternalSend(IntPtr info, bool synchronization)
 {
     ObjectAuxiliary.Call <MailClient>(info, (smtp, arguments) =>
     {
         do
         {
             NSJSVirtualMachine machine = arguments.VirtualMachine;
             if (arguments.Length <= 0)
             {
                 Throwable.ArgumentException(machine);
                 break;
             }
             MailMessage message = null;
             try
             {
                 message = ObjectAuxiliary.ToMailMessage(arguments[0]);
             }
             catch (Exception exception)
             {
                 Throwable.Exception(machine, exception);
                 break;
             }
             if (message == null)
             {
                 Throwable.ArgumentNullException(machine);
                 break;
             }
             if (synchronization)
             {
                 arguments.SetReturnValue(smtp.Send(message));
             }
             else
             {
                 NSJSFunction function        = arguments.Length > 1 ? arguments[1] as NSJSFunction : null;
                 Action <Exception> callbackt = null;
                 if (function != null)
                 {
                     callbackt = (exception) => machine.Join((sender, state) =>
                                                             function.Call(new[] { Throwable.FormatMessage(exception) }));
                     function.CrossThreading = true;
                 }
                 arguments.SetReturnValue(smtp.SendAsync(message, callbackt));
             }
         } while (false);
     });
 }
예제 #10
0
 private static void Send(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) =>
     {
         bool success  = false;
         byte[] buffer = arguments.Length > 0 ? (arguments[0] as NSJSUInt8Array)?.Buffer : null;
         if (buffer != null)
         {
             success = websocket.Send(buffer);
         }
         else
         {
             string message = arguments.Length > 0 ? (arguments[0] as NSJSString)?.Value : null;
             if (message != null)
             {
                 success = websocket.Send(message);
             }
         }
         arguments.SetReturnValue(success);
     });
 }
예제 #11
0
 private static void RollbackOrCommit(IntPtr info, bool commiting)
 {
     ObjectAuxiliary.Call <IDbTransaction>(info, (transaction, arguments) =>
     {
         try
         {
             if (commiting)
             {
                 transaction.Commit();
             }
             else
             {
                 transaction.Rollback();
             }
         }
         catch (Exception exception)
         {
             Throwable.Exception(arguments.VirtualMachine, exception);
         }
     });
 }
예제 #12
0
 private static void GetBindPort(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) => arguments.SetReturnValue(server.GetBindPort()));
 }
예제 #13
0
 private static void Write(IntPtr info)
 {
     ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments, value) => arguments.SetReturnValue(response.Write(value)));
 }
예제 #14
0
 private static void Available(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocket>(info, (websocket, arguments) => arguments.SetReturnValue(websocket.Available));
 }
예제 #15
0
 private static void Redirect(IntPtr info)
 {
     ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments, value) => response.Redirect(value));
 }
예제 #16
0
 private static void Abort(IntPtr info)
 {
     ObjectAuxiliary.Call <HTTPResponse>(info, (response, arguments) => response.Abort());
 }
예제 #17
0
 private static void Stop(IntPtr info)
 {
     ObjectAuxiliary.Call <WebSocketListener>(info, (server, arguments) => server.Stop());
 }