weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cxf...@apache.org
Subject [1/4] incubator-weex git commit: + [ios] fix websocket module crash ; load more in direction up; update websocket demo
Date Thu, 02 Mar 2017 03:23:30 GMT
Repository: incubator-weex
Updated Branches:
  refs/heads/0.11-dev 2f7dd8ab6 -> dd69c0588


+ [ios]  fix websocket module crash ;load more in direction up; update websocket demo


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/033b246d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/033b246d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/033b246d

Branch: refs/heads/0.11-dev
Commit: 033b246dd6386df3f84b6c1f456a6eea2d3dd8ca
Parents: fa1c8b0
Author: kfeagle <sunjjbobo@163.com>
Authored: Wed Mar 1 19:26:21 2017 +0800
Committer: kfeagle <sunjjbobo@163.com>
Committed: Wed Mar 1 19:26:21 2017 +0800

----------------------------------------------------------------------
 examples/module/websocket-demo.we               | 222 ++++++++++---------
 .../Sources/Component/WXScrollerComponent.m     |   2 +-
 .../WeexSDK/Sources/Module/WXWebSocketModule.m  |   4 +-
 3 files changed, 120 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/033b246d/examples/module/websocket-demo.we
----------------------------------------------------------------------
diff --git a/examples/module/websocket-demo.we b/examples/module/websocket-demo.we
index 11d9c11..4fa338c 100644
--- a/examples/module/websocket-demo.we
+++ b/examples/module/websocket-demo.we
@@ -1,112 +1,124 @@
 <template>
-    <scroller>
-        <wxc-panel title="websocket" type="primary">
-            <input
-                    type="text"
-                    placeholder="please input message to send"
-                    class="input"
-                    autofocus="false"
-                    value=""
-                    onchange="onchange"
-                    oninput="oninput"
-                    id = "input"
-            />
-            <div style="flex-direction: row; justify-content: center;">
-                <wxc-button value="connect" size="small"  type="primary" onclick="{{connect}}"></wxc-button>
-                <wxc-button value="send" size="small" onclick="{{send}}" type="primary"
style="margin-left:20px;"></wxc-button>
-                <wxc-button value="close" size="small" onclick="{{close}}" type="primary"
style="margin-left:20px;"></wxc-button>
-
-            </div>
-
-            <wxc-panel title="method = send">
-                <text>{{sendinfo}}</text>
-            </wxc-panel>
-
-            <wxc-panel title="method = onopen">
-                <text>{{onopeninfo}}</text>
-            </wxc-panel>
-
-            <wxc-panel title="method = onmessage">
-                <text>{{onmessage}}</text>
-            </wxc-panel>
-
-            <wxc-panel title="method = onclose">
-                <text>{{oncloseinfo}}</text>
-            </wxc-panel>
-
-            <wxc-panel title="method = onerror">
-                <text>{{onerrorinfo}}</text>
-            </wxc-panel>
-
-            <wxc-panel title="method = close">
-                <text>{{closeinfo}}</text>
-            </wxc-panel>
-        </wxc-panel>
-    </scroller>
+  <scroller>
+    <div>
+      <div style="background-color: #286090">
+        <text class="title" style="height: 80 ;padding: 20;color: #FFFFFF">websocket</text>
+      </div>
+      <input
+              type="text"
+              placeholder="please input message to send"
+              class="input"
+              autofocus="false"
+              value=""
+              onchange="onchange"
+              oninput="oninput"
+              id = "input"
+      />
+      <div style="flex-direction: row; justify-content: center;">
+        <text class="button" onclick="{{connect}}">connect</text>
+        <text class="button" onclick="{{send}}">send</text>
+        <text class="button" onclick="{{close}}">close</text>
+      </div>
+      <div style="background-color: #D3D3D3;margin-top: 20">
+        <text class="title" style="height: 80 ;padding: 20;color: #000000">method =
send</text>
+      </div>
+      <text style="color: #000000;height: 80">{{sendinfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: #000000">method =
onopen</text>
+      </div>
+      <text style="color: #000000;height: 80">{{onopeninfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: #000000">method =
onmessage</text>
+      </div>
+      <text style="color: #000000;height: 100">{{onmessage}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: #000000">method =
onclose</text>
+      </div>
+      <text style="color: #000000;height: 80">{{oncloseinfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: #000000">method =
onerror</text>
+      </div>
+      <text style="color: #000000;height: 80">{{onerrorinfo}}</text>
+      <div style="background-color: #D3D3D3">
+        <text class="title" style="height: 80 ;padding: 20;color: #000000">method =
close</text>
+      </div>
+      <text style="color: #000000;height: 80">{{closeinfo}}</text>
+    </div>
+    </div>
+  </scroller>
 </template>
-
 <style>
-    .input {
-        font-size: 40px;
-        height: 80px;
-        width: 600px;
-    }
+  .input {
+    font-size: 40;
+    height: 80;
+    width: 600;
+  }
+  .button {
+    font-size: 36;
+    width: 150;
+    color: #41B883;
+    text-align: center;
+    padding-top: 10;
+    padding-bottom: 10;
+    border-width: 2;
+    border-style: solid;
+    margin-right: 20;
+    border-color: rgb(162, 217, 192);
+    background-color: rgba(162, 217, 192, 0.2);
+  }
 </style>
-
 <script>
-    require('weex-components');
-    var navigator = require('@weex-module/navigator');
-    var modal = require('@weex-module/modal');
-    var websocket = require('@weex-module/webSocket');
-    module.exports = {
-        data: {
-            connectinfo: '',
-            sendinfo: '',
-            onopeninfo: '',
-            onmessage: '',
-            oncloseinfo: '',
-            onerrorinfo: '',
-            closeinfo: '',
-            txtInput:'',
-            navBarHeight: 88,
-            title: 'Navigator',
-            dir: 'examples',
-            baseURL: '',
-        },
-        methods: {
-            connect:function() {
-                websocket.WebSocket('ws://115.29.193.48:8088','');
-                var self = this;
-                websocket.onopen = function(e)
-                {
-                    self.onopeninfo = e;
-                }
-                websocket.onmessage = function(e)
-                {
-                    self.onmessage = e.data;
-                }
-                websocket.onerror = function(e)
-                {
-                    self.onerrorinfo = e.data;
-                }
-                websocket.onclose = function(e)
-                {
-                    self.onerrorinfo = e.code;
-                }
-            },
-            send:function(e) {
-                var input = this.$el('input');
-                input.blur();
-                websocket.send(this.txtInput);
-                this.sendinfo = this.txtInput;
-
-            },
-            oninput: function(event) {
-                this.txtInput = event.value;
-            },
-            close:function(e) {
-                websocket.close();
-            },
+  var websocket = require('@weex-module/webSocket');
+  module.exports = {
+    data: {
+      connectinfo: '',
+      sendinfo: '',
+      onopeninfo: '',
+      onmessage: '',
+      oncloseinfo: '',
+      onerrorinfo: '',
+      closeinfo: '',
+      txtInput:'',
+      navBarHeight: 88,
+      title: 'Navigator',
+      dir: 'examples',
+      baseURL: '',
+    },
+    methods: {
+      connect:function() {
+        websocket.WebSocket('ws://echo.websocket.org','');
+        var self = this;
+        self.onopeninfo = 'connecting...'
+        websocket.onopen = function(e)
+        {
+          self.onopeninfo = 'websocket open';
+        }
+        websocket.onmessage = function(e)
+        {
+          self.onmessage = e.data;
+        }
+        websocket.onerror = function(e)
+        {
+          self.onerrorinfo = e.data;
         }
-    };
+        websocket.onclose = function(e)
+        {
+          self.onopeninfo = '';
+          self.onerrorinfo = e.code;
+        }
+      },
+      send:function(e) {
+        var input = this.$el('input');
+        input.blur();
+        websocket.send(this.txtInput);
+        this.sendinfo = this.txtInput;
+      },
+      oninput: function(event) {
+        this.txtInput = event.value;
+      },
+      close:function(e) {
+        websocket.close();
+      },
+    }
+  };
 </script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/033b246d/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
index d0bef9b..0e40c88 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
@@ -423,6 +423,7 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
         _direction = @"down";
     } else if(_lastContentOffset.y < scrollView.contentOffset.y) {
         _direction = @"up";
+        [self handleLoadMore];
     }
    
     _lastContentOffset = scrollView.contentOffset;
@@ -439,7 +440,6 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
 
     // check sticky
     [self adjustSticky];
-    [self handleLoadMore];
     [self handleAppear];
     
     if (self.onScroll) {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/033b246d/ios/sdk/WeexSDK/Sources/Module/WXWebSocketModule.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXWebSocketModule.m b/ios/sdk/WeexSDK/Sources/Module/WXWebSocketModule.m
index 239c34c..ebcdf5b 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXWebSocketModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXWebSocketModule.m
@@ -67,7 +67,7 @@ WX_EXPORT_METHOD(@selector(onclose:))
         if (weakSelf) {
             WXLogError(@":( Websocket Failed With Error %@", error);
             NSMutableDictionary *dict = [NSMutableDictionary new];
-            [dict setObject:error.userInfo forKey:@"data"];
+            [dict setObject:error.userInfo?[WXUtility JSONString:error.userInfo]:@"" forKey:@"data"];
             if (weakSelf.errorCallBack) {
                 weakSelf.errorCallBack(dict, true);
             }
@@ -79,7 +79,7 @@ WX_EXPORT_METHOD(@selector(onclose:))
                 WXLogInfo(@"Websocket colse ");
                 NSMutableDictionary * callbackRsp = [[NSMutableDictionary alloc] init];
                 [callbackRsp setObject:[NSNumber numberWithInteger:code] forKey:@"code"];
-                [callbackRsp setObject:reason forKey:@"reason"];
+                [callbackRsp setObject:reason?reason:@"" forKey:@"reason"];
                 [callbackRsp setObject:wasClean?@true:@false forKey:@"wasClean"];
                 if (weakSelf.closeCallBack) {
                     weakSelf.closeCallBack(callbackRsp,false);


Mime
View raw message