2017-02-23 7 views
1

私はチャットアプリケーションを開発しています。これはSignalRとIonicを使用しています。イオン側でエラーが発生します。 LへSignalRとIonicを使用したチャットアプリケーション

Startup.cs

using System; 
using System.Threading.Tasks; 
using Microsoft.Owin; 
using Owin; 

[assembly: OwinStartup(typeof(SignalR.Startup))] 

    namespace SignalR 
{ 
    public class Startup 
    { 
     public void Configuration(IAppBuilder app) 
      { 

     app.MapSignalR(); 
     } 
    } 
    } 

ChatHub.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using Microsoft.AspNet.SignalR; 

    namespace SignalR 
{ 
     public class ChatHub : Hub 
    { 


     public void Send(string username,string message) 

     { 
     Clients.All.sendMessage(username,message); 

     } 
     } 
    } 

controller.js

angular.module('starter.controllers', []) 

.controller('DashCtrl', function ($scope) { 


$scope.name = 'Onur'; // holds the user's name 
$scope.message = ''; // holds the new message 
$scope.messages = []; // collection of messages coming from server 
$scope.chatHub = null; // holds the reference to hub 

$scope.chatHub = $.connection.chatHub; // initializes hub 
$.connection.hub.start(); // starts hub 

// register a client method on hub to be invoked by the server 
$scope.chatHub.client.broadcastMessage = function (name, message) { 
    var newMessage = name + ' says: ' + message; 

    // push the newly coming message to the collection of messages 
    $scope.messages.push(newMessage); 
    $scope.$apply(); 
}; 

$scope.newMessage = function() { 
    // sends a new message to the server 
    $scope.chatHub.server.sendMessage($scope.name, $scope.message); 

    $scope.message = ''; 
}; 

}) 

Faield OADリソース ハブ(0,0)

は例外TypeError:未定義

私はerrors.Whereを取得していますのプロパティ 'chatHub' を読み取ることができませんよ、私は私が

答えて

0

あなたが開始する必要がありますwrong.Helpやっクライアントメソッドを登録した後のハブそれは動作するはずです。

関連する問題