aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Examples/SimpleApp2/MyClientView.cs
blob: 4ef3c942f5c012d9c24b907ae8e78091b35f6289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim;
using libsecondlife;
using OpenSim.Framework.Interfaces;
using System.Net;
using libsecondlife.Packets;
using OpenSim.Assets;
using OpenSim.Framework.Types;
using OpenSim.Framework;
using OpenSim.Caches;

namespace SimpleApp2
{
    public class MyClientView : ClientView
    {
        private float[] m_map;
        private Dictionary<uint, IClientAPI> m_clientAPIs;

        public MyClientView(float[] map, Dictionary<uint, IClientAPI> clientAPIs, EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions)
            : base(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions)
        {
            m_map = map;
            m_clientAPIs = clientAPIs;
            
            OnRegionHandShakeReply += RegionHandShakeReplyHandler;
            OnChatFromViewer += ChatHandler;
            OnRequestWearables += RequestWearablesHandler;
            OnCompleteMovementToRegion += CompleteMovementToRegionHandler;
        }

        private void ChatHandler(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
        {            
            // Echo it (so you know what you typed)
            SendChatMessage(message, type, fromPos, fromName, fromAgentID);
            SendChatMessage("Ready.", 1, fromPos, "System", LLUUID.Zero);
        }
        
        private void CompleteMovementToRegionHandler()
        {
            LLVector3 pos = new LLVector3(128, 128, 128);

            MoveAgentIntoRegion(m_world.RegionInfo, pos, LLVector3.Zero );

            SendAvatarData( m_world.RegionInfo, FirstName,
                                           LastName, AgentId, 0,
                                           pos);

            SendChatMessage("Welcome to My World.", 1, pos, "System", LLUUID.Zero);

            
                
            // OpenSim.world.Primitive prim = new OpenSim.world.Primitive( m_clientAPIs, m_world.RegionInfo.RegionHandle, m_world, AgentId );

           // SendNewPrim( prim );
            
        }

        private void RegionHandShakeReplyHandler(IClientAPI client)
        {
            client.SendLayerData(m_map);
        }

        private void RequestWearablesHandler(IClientAPI client)
        {
            SendWearables(AvatarWearable.DefaultWearables);
        }
    }
}