2011-12-14 15 views
10

बहुत आसान सवाल। क्लाइंट जो अभी जुड़ा हुआ है, उसे कोई संदेश क्यों नहीं मिलता है, लेकिन अन्य सभी क्लाइंट प्रसारण प्राप्त करते हैं? एक संदेश कनेक्ट करने वाले क्लाइंट को भेजने का सही तरीका क्या है?सिग्नलआर ऑनकनेक्टेड - कनेक्टेड क्लाइंट भेजना एक संदेश

protected override void OnConnected(HttpContextBase context, string clientId) 
{  
    GameAction message = new GameAction(); 
    message.text = "Player connected"; 
    Connection.Broadcast(serializer.Serialize(message)); 

    GameAction gamestate = new GameAction(); 
    gamestate.text = "Some client specific info";  
    Send(clientId, serializer.Serialize(gamestate));  
} 

उत्तर

3

मुझे लगता है कि आप एक कॉल वापस समारोह एक connection.start में() फ़ंक्शन अपने जावास्क्रिप्ट में डाल दिया और अपने आदेश को पुन: भेजने चाहिए। जेएसओएन में अलग-अलग प्रकार के प्रसारण संदेश और गूंज संदेश आपको शामिल होने के बाद कनेक्शन की स्थिति का पता लगाने में मदद कर सकता है ... घंटी मेरे लिए काम करती हैं ..

..... 
connection.start({ callback: function() { 
var username = getCookie("username"); 
connection.send(window.JSON.stringify({ type: 0, value: username })); 
} 
}); 
...... 
संबंधित मुद्दे