titanium-mobile - 钛聊天实现

标签 titanium-mobile

我有一个任务是实现一个基于聊天的应用程序,以使用 Web 服务 api 调用访问服务器上可用的私有(private)数据。显示 Web 服务器上的所有可用用户并与这些人聊天。钛开发不可能支持iPhone/Android 聊天应用程序。如果可能的话,让我指导实现相同的操作。

最佳答案

是的,当然有可能。有一百万种方法可以做到这一点,你的问题不是很清楚。

如果它完全基于网络服务then just use this.

下面是发布到 Web 服务并发送 JSON 对象的快速示例:

 var getChatMessages = Ti.Network.createHTTPClient({
        onload : function(e) {
             var doSomethignWithThis = this.responseText;
        },
        onerror : function(e) {
            Ti.API.info(this.responseText);
            Ti.API.info('SelectActivityStepsByKeyList webservice failed with message : ' + e.error);
        }
    });
    getChatMessages.open('POST', 'http://yourchatserver/GetChats');
    getChatMessages.setRequestHeader("Content-Type", "application/json");
    getChatMessages.send({"message" : "How is everyone today?", "user" : "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="660b03260b034805090b" rel="noreferrer noopener nofollow">[email protected]</a>});

这对于钛合金来说并不困难,困难的部分是在服务器端。 Here is an example project that accomplishes chat through the use of the socket.io library.这对您来说可能是更好的方法。该链接包含有关其工作原理的视频以及完整的源代码。

关于titanium-mobile - 钛聊天实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12425327/

相关文章:

ios - 如何在使用 Appcelerator 的 Titanium 构建的 iOS native 应用程序中使用 janrain engage 小部件?

javascript - 钛金属启动和停止声音

javascript - 如何在 iOS Titanium 中创建复选框?

ios - 在 Titanium Studio 中处理 iOS 的方向变化?

iphone - 在 Titanium SDK 中重新创建此动画

android - 如何获得触摸点(顶部和左侧)而不考虑 Titanium 中的 View 和窗口

java - 无法在 Appcelerator Studio 中构建

java - 想知道钛加速器的功能吗?

titanium - Appcelerator钛: Code Sign error: No codesigning identities found

javascript - 钛合金静态和动态绘图/绘画